ASP.NET MVC RC Refresh

Hello there. :)

On Tuesday, we announced the release candidate for ASP.NET MVC. While there is much new in there to be excited about and many many bug fixes, there were two changes introduced in the RC that broke some scenarios which previously worked in the Beta, as reported by customers.

We’ve updated the Release Candidate with a refresh that addresses these two issues. You can use the recently released Microsoft Web Platform Installer 1.0 to install ASP.NET MVC RC Refresh. It happens to be a handy tool for installing not just ASP.NET MVC, but everything you might need to use ASP.NET MVC such as Visual Web Developer Express 2008 SP1.

The link on the official download page appears to be updated with the new MSI (we pushed it out yesterday), but we’ve experienced some odd proxy caching issues etc where some people were still getting the old MSI.

In order to be safe, you can get the download directly from this download link. I don’t anticipate any problems with that link, but being paranoid, the way to fully ensure you have the refresh is to right click on the downloaded file, select the Digital Signatures tab, and make sure the Time Stamp says Wednesday, January 28 and not Friday, January 23.

msi-props

Don’t forget to fully uninstall the previous RC before installing this one.

Also note that this refresh does not address the Controls Collection Cannot Be Modified issue I reported recently. We will address that soon. The following describes the issues that this refresh does fix.

The first change was that we changed our helper methods that generate URLs and links to now generate relative paths instead of absolute paths. This caused problems with several AJAX scenarios.

The fix to this in the refresh was to roll back that check-in so the behavior went back to the way it was in the Beta. We will not use relative paths, and we have no intention of re-introducing the generation of relative paths. Because we rolled back this change to a known good state, we feel very confident in the current behavior. URL generation should work the same way it did back in the Beta.

The other regression is that in some cases, the RouteUrl (and thus RouteLink) methods return an empty string when you specify a route name, but the route has default parameters which are not parameters in the URL.

For example, if you have the following route:

routes.MapRoute("route-name", 
  "foo/bar", 
  new {controller="Home", action="index"});

Notice that controller has default value, but is not part of the URL. If you then specify:

<%= Url.RouteUrl("route-name") %>

You might expect that it would use that route to render the URL, but it doesn’t. This bug was introduced when we refactored all our url generating helpers to call into a common method. It turns out, however, that our RouteUrl methods (aka non-MVC specific) should have subtly different behavior than the MVC specific methods (such as Action). We added a flag to the common method so that this difference is taken into consideration. This was a fix that did not have a large surface area.

Another thing we did was update all our test cases (both unit tests and automated functional tests) with scenarios reported to us by customers. So now, we have these types of cases well covered.

If you downloaded the Release Candidate before today, you should check the digital signature timestamp as I described earlier and if it’s the old one, I recommend you go and download the refresh via the Web Platform Installer or directly at the URL I mentioned earlier.

As I mentioned before, we are very excited about this release and hope that you are enjoying writing code with it. :)

Technorati Tags: ,

What others have said

Requesting Gravatar... Joachim Jan 30, 2009 5:13 PM
# re: ASP.NET MVC RC Refresh
I have the timestamp January 29, 02:14:10 AM. Seems that the timestamp depends on the timezone (+1, Germany for me). Just to let you know ;-)
Requesting Gravatar... Steve Jan 30, 2009 6:21 PM
# re: ASP.NET MVC RC Refresh
Thanks Phil.

One problem I'm having is that we, as well as most larger setups, separate out the controllers from the views.

It appears all the new GUI features like 'goto controller' do not work in this case ?

Is there a workaround for this? If not, any chance it gets addressed before actual release ?

Thanks
Requesting Gravatar... Elijah Manor Jan 30, 2009 7:30 PM
# re: ASP.NET MVC RC Refresh
Well, I am glad I waited to do the upgrade then. You guys work quick! Thanks for all the hard work!

I look forward to integrated the xVal framework with RC1 as well. I wonder if it has been updated yet to support it?

http://twitter.com/elijahmanor
http://zi.ma/webdev
Requesting Gravatar... Barry Dahlberg Jan 30, 2009 8:37 PM
# re: ASP.NET MVC RC Refresh
The web platform installer is currently failing to download the setup file and doesn't give any useful reason.
Requesting Gravatar... haacked Jan 30, 2009 8:52 PM
# re: ASP.NET MVC RC Refresh
@Barry thanks, I'll let the team know.
Requesting Gravatar... haacked Jan 30, 2009 9:43 PM
# re: ASP.NET MVC RC Refresh
@Barry, try it again. The issue has been fixed.
Requesting Gravatar... Chris Hohmann Jan 30, 2009 10:10 PM
# re: ASP.NET MVC RC Refresh
Incorrect link to this article on asp.net.
Requesting Gravatar... Emad Ibrahim Jan 31, 2009 5:20 AM
# re: ASP.NET MVC RC Refresh
Thanks for the update but I have a quick question. I have a filter that inherits from AuthorizeAttribute. I override the OnAuthorization method and call filterContext.Cancel to cancel the authorization and I also check if it to see if it is set to true.

The Cancel property doesn't exist anymore in the RC. I know that you changed the authroization filters to run first. Is that why you took it out? Will it run first regardless of Order? What if I have multiple authorization filters?

For example, I have an AuthorizeForNetworkAdmin and AuthorizeForNetwork which check if a user is authorized to access the site and the other checks if he is authorized to access it as an admin. I use that for yonkly.com since it hosts multiple "networks" each with its own subdomain.

Any suggestions on how to address this?

Thanks.
Requesting Gravatar... Ray Fan Jan 31, 2009 9:55 AM
# re: ASP.NET MVC RC Refresh
Are there any changes I need to make to any of the files I just created a project with? For example, did you change anything to the controller tests etc?
Requesting Gravatar... Simon Jan 31, 2009 12:44 PM
# re: ASP.NET MVC RC Refresh
wow! a microsoft tool that knows how to download an RC1 product. cool! i wish it had let me upgrade though instead of me having to uninstall and reinstall which is what I seemed to have to do.

So is this tool going to tell me when RC2 comes out? i'd hate to go two days without checking your blog and miss out on knowing about a release
Requesting Gravatar... simon Jan 31, 2009 2:15 PM
# re: ASP.NET MVC RC Refresh
@haacked how can we best ensure we sync the futures DLL with new versions of the core MVC framework that this tool downloads. won't there always be a new version of futures? for now the old one at least appears to work
Requesting Gravatar... haacked Jan 31, 2009 4:39 PM
# re: ASP.NET MVC RC Refresh
@Emad We removed the Cancel property because it was redundant. Just set the ActionResult property to null.

@simon we published a new version of the MVC Futures.
Requesting Gravatar... china Jan 31, 2009 6:24 PM
# re: ASP.NET MVC RC Refresh
bug, webconfig中 login -->应该为logOn
Requesting Gravatar... Chad Moran Feb 01, 2009 2:07 AM
# re: ASP.NET MVC RC Refresh
Phil, you sure that, the MVC futures you linked to works with the new refresh? I'm getting an exception when I use try to click on links generated from the generic ActionLink<T> from MVCFutures.

...

The RouteData must contain an item named 'controller' with a non-empty string value.

... stack trace ...

[InvalidOperationException: The RouteData must contain an item named 'controller' with a non-empty string value.]
System.Web.Routing.RouteData.GetRequiredString(String valueName) +18280
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +57
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +39
Requesting Gravatar... simon Feb 01, 2009 4:31 AM
# re: ASP.NET MVC RC Refresh
@haacked - thanks for the link. it seems this version hasn't changed since RC1 r0. since Microsoft.Web.Mvc refers to a non-strongly named v1.0.0.0 of System.Web.Mvc its not always clear whether or not a new version is needed.

i was hoping an outdated futures was the reason why IsAjaxRequest() was always returning false for me : stackoverflow.com/.../is-request-isajaxrequest-...
Requesting Gravatar... Emad Ibrahim Feb 01, 2009 6:49 AM
# re: ASP.NET MVC RC Refresh
Cool, that's easy enough. To cancel, set the results to null and return.

What if I wanted to check if the action has been canceled in a previous filter. I have logic like this.

if (filterContext.Cancel)
return;

Or am I using it wrong? Do I even need to do that check?
Requesting Gravatar... Mauricio Feb 01, 2009 9:17 AM
# re: ASP.NET MVC RC Refresh
I just upgraded from RC to the refreshed RC and now VS crashes when I open any aspx or ascx view :-(
Event viewer doesn't say much:
.NET Runtime version 2.0.50727.1434 - Fatal Execution Engine Error (79FEC5F0) (80131506)
I did uninstall the previous RC before installing this one...
Requesting Gravatar... haacked Feb 01, 2009 9:46 AM
# re: ASP.NET MVC RC Refresh
@Simon, did you update your .js files in your project? Or are you trying this with a brand new project?
Requesting Gravatar... haacked Feb 01, 2009 9:56 AM
# re: ASP.NET MVC RC Refresh
@Mauricio there are known issues with other VS plugins. See this Stack Overflow post and this forums post.
Requesting Gravatar... Mauricio Feb 01, 2009 1:03 PM
# re: ASP.NET MVC RC Refresh
Thanks, I just fixed it by following this advice.
Requesting Gravatar... simon Feb 01, 2009 2:12 PM
# Didn't know I had to update .js files !
@haacked - thanks phil that was it. i hadn't updated the 'MicrosoftMvcAjax.js' file but only because the release notes didnt tell me to ;) They do say 'The ASP.NET AJAX helpers were updated to send this header in requests' but it didnt actually say i had to update the .js files :-) But then they do also say "The following list describes **some** of the changes that you must make." ;-)
Requesting Gravatar... Sean M Feb 01, 2009 10:19 PM
# re: ASP.NET MVC RC Refresh
Awesome, you guys resolved the only major issue I had with the release (relative urls being generated!)
Requesting Gravatar... HeavyHenke Feb 01, 2009 10:44 PM
# re: ASP.NET MVC RC Refresh
Thanks for releasing corrections quickly!

But why didnt you name this release RC2? It would be alot easier to see what version is installed.
Requesting Gravatar... GeorgeK Feb 02, 2009 8:40 AM
# re: ASP.NET MVC RC Refresh
Phil, I'm confused. Above you write "The first change was that we changed our helper methods that generate URLs and links to now generate relative paths instead of absolute paths." Then in the next paragraph you state: "We will not use relative paths, and we have no intention of re-introducing the generation of relative paths." To me, this reads like an apparent contradiction. Can you clarify a bit?
Requesting Gravatar... haacked Feb 03, 2009 7:28 AM
# re: ASP.NET MVC RC Refresh
@GeorgeK I was relating the timeline. Our initial RC generated relative URLs, but in the refresh we realized that was a mistake and rolled back that change. We no longer plan to reintroduce that change.
Requesting Gravatar... Andrei Rinea Feb 03, 2009 12:40 PM
# Slightly offtopic... Grid in MVC Final
@Phil Haack :

I hope I am not missing something that has been said .. but will there be something in the **FINAL** version of the ASP.NET MVC Framework that would help simulate a GridView? Paging, sorting and filtering would be nice...

Thank you for your time.
Requesting Gravatar... Saurabh Feb 03, 2009 11:26 PM
# re: ASP.NET MVC RC Refresh
Hi Phil.....

Can you please tell us how to load a UserControl in RC Refresh b'coz i have seen in last version of MVC, i loads UC like
<%= RenderUserControl("~/Views/Home/TestUC.ascx")%>

but in RC Refresh there is no option like "RenderUserControl".
plz help us out

Kind Regards,
Saurabh
Requesting Gravatar... Saurabh Feb 03, 2009 11:40 PM
# re: ASP.NET MVC RC Refresh
Well ......i got the Answer.......

it should be
<% Html.RenderPartial("~/Views/Home/TestUC.ascx", m); %>

thanx for the RC Refresh

Kind Regards
Saurabh
Requesting Gravatar... John Meyer Feb 04, 2009 8:13 AM
# re: ASP.NET MVC RC Refresh
I wrote the following to get around not being able to call the MVC functions because they're internal, but I have a question...


public static String GetUrlForLink(this HtmlHelper htmlHelper, String routeName, String actionName, String controllerName, String protocol, String hostName, String fragment, RouteValueDictionary routeValues)
{
var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext, htmlHelper.RouteCollection);
String url = null;
if (routeName != null) {
url = urlHelper.RouteUrl(routeName, routeValues, protocol, hostName);
} else {
url = urlHelper.Action(actionName, controllerName, routeValues, protocol, hostName);
}
if (!String.IsNullOrEmpty(fragment)) {
url = String.Concat(url, "#", fragment);
}
return url;
}


in the call to urlHelper.Action, it's possible that controller could be null (I basically duplicated the signatures from LinkExtensions.cs, changing the bodies to make image links)... do I need a null coalescing (??) operator on the controller parameter to get the expected functionality, and if so what should it be? (htmlHelper.ViewContext.RouteData.Values["controller"] as String)?

Thanks!
Requesting Gravatar... Saurabh Feb 04, 2009 10:53 PM
# re: ASP.NET MVC RC Refresh
Hi Haacked....

I have one question.....why there is two web.config files (one is at rootfolder and anthor is in "Views" folder).

Kind Regards,
Saurabh
Requesting Gravatar... Jirapong Nanta Feb 05, 2009 6:46 AM
# re: ASP.NET MVC RC Refresh
Ok, The Spec# crashed the installation on VS.NET Template installing.
Requesting Gravatar... Mike Thomas Feb 06, 2009 7:04 AM
# re: ASP.NET MVC RC Refresh
Not sure if this is the right venue - but do you think it would be possible to make the class System.Web.Mvc.ViewTypeParserFilter public rather than internal (as it is now)?

Thanks, Mike
Requesting Gravatar... Evgeny Feb 09, 2009 8:45 AM
# re: ASP.NET MVC RC Refresh
Hi,

Is there a sources refresh somewhere?
Requesting Gravatar... darren Feb 09, 2009 10:34 AM
# re: ASP.NET MVC RC Refresh
I noticed the fatal execution error when I installed MVC RC. I traced it down to an issue with that and AnkhSvn. I turned off AnkhSvn as my source control closed the solution and then reopened it. This seemed to have solved the problem temporarily because I need to use AnkhSvn and other addins. Is there a fix out there for this??
Requesting Gravatar... haacked Feb 09, 2009 8:33 PM
# re: ASP.NET MVC RC Refresh
@Evgeny the source for the RC is available on CodePlex.
Requesting Gravatar... Evgeny Feb 10, 2009 2:44 AM
# re: ASP.NET MVC RC Refresh
@haacked Is it sources of the refresh? I just checked the sources for AssemblyFileVersion. It is 1.0.40112.0 but the DLL file version is 1.0.40128.0
Requesting Gravatar... George Mauer Feb 10, 2009 7:01 AM
# re: ASP.NET MVC RC Refresh
Gah! Error while installing just like the last one. The only recommendation I've been able to get is to uninstall all of my add-ons which would be quite a hassle
Requesting Gravatar... Solo stay Feb 12, 2009 4:35 AM
# why is MVC RC raising exceptions on UI on reading dbnull values from datasource
Hi, i just upgraded to the latest MVC RC. i am binding to datatable rows but i keep getting exceptions with the html helpers (textbox,dropdownlist) when page loading or reading dbnull values from the dataset...The beta threw no exceptions. what could be the possible thing i'm missing
Requesting Gravatar... haacked Feb 19, 2009 9:44 AM
# re: ASP.NET MVC RC Refresh
@Emad correction to my last comment to you. Set the Result property to new HttpUnauthorizedResult(). Sorry for that.
Requesting Gravatar... Jason Cochran Feb 19, 2009 3:46 PM
# re: ASP.NET MVC RC Refresh
Phil, are there any plans to add functionality to the framework to auto-detect whether a controller's action link should be prefixed with HTTPS vs. HTTP? Is there a good workaround in the meantime? Writing an extension method (a la .ToSslUrl()) will work for links but form actions will not as far as I know. I am currently using an ActionFilterAttribute to redirect if the action is decorated, but there has to be a better way. Thanks!
Requesting Gravatar... Andrew Gunn Feb 23, 2009 1:22 AM
# re: ASP.NET MVC RC Refresh
Is the Refresh source code avaialbe online? I ask because I want to know more about the changes that fixed the problems with Html.RouteLink. I've created my own ASP.NET MVC control library (www.codeproject.com/.../MVCCustomControls.aspx) which uses some functionaility that was marked as internal or private - methods like GenerateUrl. My only reason for copying (thus making them public) is because I couldn't see any other way of utilising things like protocol, host and fragment to create a URL along with route name or action/controller names. Thanks.
Requesting Gravatar... KristoferA Feb 23, 2009 6:50 AM
# re: ASP.NET MVC RC Refresh
@Mauricio @haacked

I set up a system where I was able to reproduce this (or at least a very similar) problem and did some troubleshooting.

As a workaround, I wrote an add-in that changes the load order of assemblies when working with web projects. This add-in solves the VS-crash-problem on my repro system and may or may not solve it on other systems; further testing by others affected by this bug is required to confirm this.

The new add-in can be downloaded from www.huagati.com/.../HuagatiWebProjectLoader.zip

It does not yet have an installer but installation is straightforward; download the file and unzip it into your Visual Studio 2008 add-in directory; typically located at \Users[username]\Documents\Visual Studio 2008\Addins on Windows Vista, or \Documents And Settings[username]\My Documents\Visual Studio 2008\Addins on Windows XP. To uninstall, simply remove the same files.
Requesting Gravatar... Jessica Mar 05, 2009 1:59 PM
# re: ASP.NET MVC RC Refresh
One thing I found difficult since the automatic inclusion of jQuery was figuring out how to include the scripts to a) work regardless of the path level, and b) get intellisense to work.

It would be nice if the default site.master template included the jquery & ajax scripts. I found I needed to use the <%= Url.Content %> thing in the src attribute, then use an if(false) code block to use relative paths to the script files in order to get the intellisense.

Given it's non-trivial if you're not familiar with the quirks of script files and paths, it seems better to have it set up by default. It's not like it's hard to edit the master page, and most people would be customising it anyway.
Requesting Gravatar... haacked Mar 06, 2009 9:36 AM
# re: ASP.NET MVC RC Refresh
@Jessica if you're not planning to host your site in a virtual app, I'd just use an absolute path...

/scripts/jQuery-###.js

But yeah, I agree with the problem of using Url.Content... We'll be looking at ideas to make that better.

What do you have to say?

(will show your gravatar)
Please add 1 and 7 and type the answer here: