PRB: Action Attribute Always Uses Current Page for Server-side Form Tags in ASP.NET (327600)



The information in this article applies to:

  • Microsoft ASP.NET (included with the .NET Framework 1.1)
  • Microsoft ASP.NET (included with the .NET Framework) 1.0

This article was previously published under Q327600

SYMPTOMS

When you declaratively set the action attribute for a server-side <FORM> tag in an .aspx page to anything other than the current page, the value appears to be ignored. In the HTML source, the action attribute is always the current page, regardless of how you set the value at design time.

CAUSE

In ASP.NET, you must include the runat=server attribute value for a <FORM> tag when you use server controls. When you set a <FORM> tag to use runat=server, the action attribute is always set to use the current page. By controlling the action attribute so that it is always set to the same page reduces potential view state issues and other related unknown issues that may occur.

RESOLUTION

Although the action attribute is always set so that an .aspx page posts to itself, you can use other methods to get the result that you want. For example, you can call Response.Redirect in server-side code. The page will post back to itself and then redirect to the destination page based on logic in an event handler. For more information and for a sample that uses Response.Redirect, see the References section of this article.

STATUS

This behavior is by design.

REFERENCES

For additional information about how to use Response.Redirect in ASP.NET, click the following article numbers to view the articles in the Microsoft Knowledge Base:

312063 HOW TO: Use Response.Redirect in ASP.NET with Visual Basic .NET

307903 HOW TO: Use Response.Redirect in ASP.NET with Visual C# .NET


Modification Type:MinorLast Reviewed:7/8/2003
Keywords:kbprb kbWebForms KB327600 kbAudDeveloper