0

This is what I'm trying to implement:

<form id="form1" runat="server" action="<%= AllowedURL() %>">

The other variable is without =

<form id="form1" runat="server" action="<% AllowedURL() %>">

But both throws a 400 Bad Request.

In the url of the page I see this:

example.com/<%=%20AllowedURL()%20%>

Is there something to modify? Thanks in advance

1
  • use <%# ... %> Commented Feb 21 at 19:20

1 Answer 1

2

There are restrictions for using <%=...%> constructs inside server tags. Solution is either using data binding or setting the form action in code behind.

Solution 1: using data binding

Protected Sub Page_Load() Handles Me.Load
    form1.DataBind()
End Sub
<form id="form1" runat="server" action="<%#AllowedURL()%>">

Solution 2: setting action property in code behind

Protected Sub Page_Load() Handles Me.Load
    If Not IsPostBack Then
        form1.Action = AllowedURL()
    End If
End Sub
<form id="form1" runat="server">
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.