This is the row I’m having problems with:
<% using(Html.BeginForm("Create#result", "Report", FormMethod.Post)) { %>
Using C# 3.5 and MVC2 the form was rendered like this:
<form action="/Report.aspx/Create#result" method="post">
Now with C# 4.0 and MVC2 the form is rendered like this:
<form action="/Report.aspx/Create%23result" method="post">
This causes problems:
System.Web.HttpException (0x80004005): A public action method 'Create#result' was not found
I think the new behaviour is problematic and I don’t want the hash escaped.
Where does it occur?
Can I change the behaviour?
The MVC version should be updated at some time, but I was working on another part when this behaviour started causing problems.
Update
I solved it by updating the form action using jquery on the client.
The form
<% using(Html.BeginForm("Create", "Report", FormMethod.Post, new { id = "frmReport" })) { %>
Javascript
var frmReport = $("#frmReport");
if (0 < frmReport.length) {
var action = frmReport.attr("action");
action = action + "#result";
frmReport.attr("action", action);
}
This occurs deep within a MVC class
System.Web.Mvc.TagBuildermeaning that there probably isn’t a lot you can do about it. I wouldn’t be surprised if this code hasn’t changed, but that the underlying html encoding function was modified with .NET 4 instead.That said I’m surprised this was working for you in the first place, I believe some browsers (IE) don’t support hashtags in form postbacks.