Home Dashboard Directory Help
Search

Form action is blank on default document, breaking HTML5 validation by EvilDr


Status: 

Closed
 as Accepted Help for as Accepted


1
0
Sign in
to vote
Type: Bug
ID: 785585
Opened: 4/25/2013 8:48:39 AM
Access Restriction: Public
2
Workaround(s)
view
0
User(s) can reproduce this bug

Description


I know this is officially documented as a breaking change, but I think the result is bad news for all developers trying to learn HTML5 (http://www.asp.net/whitepapers/aspnet4/breaking-changes#0.1__Toc256770154).

When working on a HTML5 site and no page is specified (e.g. www,mysite.com), the default document renders with an empty form action property, e.g.

<form method="post" action="" id="form1">

This immediately fails HTML5 validation for the default document. All other documents where the document file name is included in the URL works okay.

To encourage more widespread use of ASP.NET with new developers, surely this is a move in the wrong direction.

I have posted a workaround for anyone stumbling across this page via a search, but feel a more robust solution is required from the framework :-)
Details
Sign in to post a comment.
Posted by Microsoft on 4/29/2014 at 12:30 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from: http://go.microsoft.com/?linkid=9832436
Posted by EvilDr on 4/30/2013 at 1:50 AM
Hi

Thanks, I can confirm this behaviour when <httpRuntime targetFramework="4.5"/> is included in web.config (which it isn't by default).

Could <httpRuntime targetFramework="4.5"/> be included in the web.config template for a new site when this version of the framework is defined? This would avoid less-experienced developers wondering what is going on!
Posted by Microsoft on 4/29/2013 at 3:19 PM
This behavior was changed again in ASP.NET 4.5 so that the action attribute is rendered with a value of "./". The application must however specfically target 4.5 in its web.config via the httpRuntime element.
Posted by Microsoft on 4/26/2013 at 1:20 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 4/25/2013 at 8:54 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by EvilDr on 4/25/2013 at 8:49 AM
Code doesn't display well here, so see solution at the end of http://stackoverflow.com/questions/9131966/asp-net-doesnt-populate-action-of-the-server-form-when-released
Posted by EvilDr on 4/25/2013 at 8:48 AM
    Protected Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender
        If Not Page.IsPostBack Then
            If Page.Form.Action = String.Empty Then
                Page.Form.Action = Request.Url.AbsolutePath    ' http://www.asp.net/whitepapers/aspnet4/breaking-changes#0.1__Toc256770154
            End If
        End If
    End Sub