ASP.NET MVC RC Refresh

asp.net mvc, asp.net 0 comments suggest edit

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. :)

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.

Comments

avatar

44 responses

  1. Avatar for Joachim
    Joachim January 30th, 2009

    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 ;-)

  2. Avatar for Steve
    Steve January 30th, 2009

    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

  3. Avatar for Elijah Manor
    Elijah Manor January 30th, 2009

    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

  4. Avatar for Barry Dahlberg
    Barry Dahlberg January 30th, 2009

    The web platform installer is currently failing to download the setup file and doesn't give any useful reason.

  5. Avatar for haacked
    haacked January 30th, 2009

    @Barry thanks, I'll let the team know.

  6. Avatar for haacked
    haacked January 30th, 2009

    @Barry, try it again. The issue has been fixed.

  7. Avatar for Chris Hohmann
    Chris Hohmann January 30th, 2009

    Incorrect link to this article on asp.net.

  8. Avatar for Emad Ibrahim
    Emad Ibrahim January 30th, 2009

    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.

  9. Avatar for Ray Fan
    Ray Fan January 30th, 2009

    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?

  10. Avatar for Simon
    Simon January 31st, 2009

    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

  11. Avatar for simon
    simon January 31st, 2009

    @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

  12. Avatar for haacked
    haacked January 31st, 2009

    @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.

  13. Avatar for china
    china January 31st, 2009

    bug, webconfig中 login -->应该为logOn

  14. Avatar for Chad Moran
    Chad Moran January 31st, 2009

    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

  15. Avatar for simon
    simon January 31st, 2009

    @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-...

  16. Avatar for Emad Ibrahim
    Emad Ibrahim January 31st, 2009

    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?

  17. Avatar for Mauricio
    Mauricio January 31st, 2009

    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...

  18. Avatar for haacked
    haacked January 31st, 2009

    @Simon, did you update your .js files in your project? Or are you trying this with a brand new project?

  19. Avatar for haacked
    haacked January 31st, 2009

    @Mauricio there are known issues with other VS plugins. See this Stack Overflow post and this forums post.

  20. Avatar for Mauricio
    Mauricio February 1st, 2009

    Thanks, I just fixed it by following this advice.

  21. Avatar for simon
    simon February 1st, 2009

    @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." ;-)

  22. Avatar for Sean M
    Sean M February 1st, 2009

    Awesome, you guys resolved the only major issue I had with the release (relative urls being generated!)

  23. Avatar for HeavyHenke
    HeavyHenke February 1st, 2009

    Thanks for releasing corrections quickly!
    But why didnt you name this release RC2? It would be alot easier to see what version is installed.

  24. Avatar for GeorgeK
    GeorgeK February 1st, 2009

    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?

  25. Avatar for haacked
    haacked February 2nd, 2009

    @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.

  26. Avatar for Andrei Rînea
    Andrei Rînea February 3rd, 2009

    @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.

  27. Avatar for Saurabh
    Saurabh February 3rd, 2009

    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

  28. Avatar for Saurabh
    Saurabh February 3rd, 2009

    Well ......i got the Answer.......
    it should be
    <% Html.RenderPartial("~/Views/Home/TestUC.ascx", m); %>
    thanx for the RC Refresh
    Kind Regards
    Saurabh

  29. Avatar for John Meyer
    John Meyer February 3rd, 2009

    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!

  30. Avatar for Saurabh
    Saurabh February 4th, 2009

    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

  31. Avatar for Jirapong Nanta
    Jirapong Nanta February 4th, 2009

    Ok, The Spec# crashed the installation on VS.NET Template installing.

  32. Avatar for Mike Thomas
    Mike Thomas February 5th, 2009

    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

  33. Avatar for Evgeny
    Evgeny February 8th, 2009

    Hi,
    Is there a sources refresh somewhere?

  34. Avatar for darren
    darren February 8th, 2009

    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??

  35. Avatar for haacked
    haacked February 9th, 2009

    @Evgeny the source for the RC is available on CodePlex.

  36. Avatar for Evgeny
    Evgeny February 9th, 2009

    @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

  37. Avatar for George Mauer
    George Mauer February 9th, 2009

    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

  38. Avatar for Solo stay
    Solo stay February 11th, 2009

    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

  39. Avatar for haacked
    haacked February 18th, 2009

    @Emad correction to my last comment to you. Set the Result property to new HttpUnauthorizedResult(). Sorry for that.

  40. Avatar for Jason Cochran
    Jason Cochran February 19th, 2009

    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!

  41. Avatar for Andrew Gunn
    Andrew Gunn February 22nd, 2009

    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.

  42. Avatar for KristoferA
    KristoferA February 22nd, 2009

    @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.

  43. Avatar for Jessica
    Jessica March 5th, 2009

    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.

  44. Avatar for haacked
    haacked March 5th, 2009

    @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.