ASP.Net MVC 2 Default.aspx - asp.net-mvc

I just installed the ASP.Net MVC Preview 2 so I can have a look at some of the new features.
However when I create a new MVC 2 project it creates everything but default.aspx, is this a bug or is this handled differently in version 2 to version 1? When I run the project it just takes me to the directory listing, I assume I could just copy one from an MVC 1 project?
Edit
Just to update, if I add a default.aspx to the project with the following line in its page load then the application works fine
Response.Redirect("Home/Index");
It's just the initial route request that doesn't seem to go through the routing engine. This is when I'm running it from visual studio, I haven't yet tried deploying to IIS.

Have updated to the latest version of ASP.Net MVC 2 and the problem went a way. So I guess either something went wrong with my install or there was a problem with that version

You don't use Default.aspx for MVC. There is no 1 to 1 mapping of URLs to files.

It is not supposed to be there in ASP.NET MVC 2, you might want to check your default routes though.

Default.aspx is typically the default page out of the box in IIS and will conflict if not override your routing in MVC. If you need a "default" page use "Index.aspx."
Out of the box /Home/Index is the default page/route, of course you can change this in the Global.asax

Related

How to update MVC 1 application to MVC 3 with razor in ASP.NET MVC

I have a MVC 1 application who i want to migrate to MVC 3 last days. i make a fresh project and rewrite all logic and put in new.
at a half :- i hear that do not changes in admin. so i include the logic from old code to fresh.
now code is not worked. so all my work look like gone.
Now i thing to migrate the project not by making fresh perhaps by using old solution [proj] i have to make upgraded to MVC 3.
so i can include changes i make in new to old.
so i need a thing that:-
How i can make MVC 1 project to MVC 3 project who can work with razor. second thing i need that used old sollution not making new sollution for migration.
are you know any thing to upgrade i can MVC 1 project to MVC 3 project. How ?
Thanks for help
Martin Aatmaa has a post on how to upgrade manually from MVC 1 to MVC 2 or you could try Eilon Lipton's upgrading tool
Then from there you might be able to use MVC 3 upgrader tool also by Eilon Lipton
I'm not aware of any tools to upgrade from MVC 1 to MVC 3 directly.
Once upgraded to MVC 3 you will then have to go through each view manually and change the code from an ASPX view to a Razor view. Note that both view engines can be used along side each other in the same project.

Setting a under construction page for IIS6

I have an .NET 1.1 web app and I am upgrading to ASP.NET MVC 1.0 app in IIS6.
How do I put up a under construction page so uses see it?
And secondly how can I install the new site and test under
this scenario of having an under construction page??
Malcolm
You could use an app_offline.htm page.
#Darin is quite correct but you must make sure it's in the root. The temptation for MVC applications is to place the html file within the Views folder. This won't work.

ASP.NET MVC app not browsing to pages only Index.aspx on root

I have an MVC 1.0 app just setup but it only shows the Index.aspx page
of Home.
Seems like the routing engine is not being engaged.
I get a 404 error when i try to browse other pages.
Any ideas why this might be?
Malcolm
It's probably that the ASP.NET DLL isn't being called for your request. If you are talking about IIS, Phil Haack has a great article on how to sort it out. Note: Scroll down for .* version :)
Essentially, you are telling IIS that for every extension, it should look use the .NET DLL to run it, but don't check to see if the file exists first (because in MVC, the files don't exist).

Getting ASP.NET Mvc and Web Forms to work together

Sorry if this as already been asked.
I am currently working on a small feature and am trying to implement the ASP.NET Mvc framework into my current Web Forms web application. I have been following the Professional ASP.NET 3.5 Mvc Chapter 13 pdf document that I recently found on stackoverflow to get Web Forms and Mvc to work together. I have completed all three steps:
Added the references to the libraries System.Web.Mvc, System.Web.Routing, and System.Web.Abstractions
Added the two directories to my web application: controllers and views
Updated the web.config to load the three assemblies mentioned in step one and registered the UrlRoutingModule HttpModule. I also added the initial routing settings to my Global.asax file
RouteTable.Routes.MapRoute(
"Default", "{controller}/{action}/{id}", new { controller = "Support", action = "Index", id = "" }
);
Once I try and run my newly created page following the ASP.NET Mvc framework I get a NullReferenceException on the following piece of code:
<%= Html.Encode(ViewData["Message"]) %>
In my controller I have ViewData["Message"] being set to "Message!" just as a test. Have I missed something setting my web application to work with ASP.NET Mvc?
Any help would be greatly appreciated.
Thanks,
From playing with the early betas, until today, I find it easier to create a new MVC application and "import" my exsiting files into the solution than it is to get all of the settings right in an existing application. I see no reason to get hot and heavy over setting up plumbing I can have written for me from a template. Perhaps I am just too lazy.
I find that I can get "legacy ASP.NET" web forms working fine with MVC. The only dink to the whole project is getting the app routed to my default.aspx to begin with. Much easier than running through multiple steps to include MVC.
I know this is not a direct answer to your question, but I think trying it will solve your problem, as well. Another benefit is you leave the old "legacy" source in case a bug fix comes in. But, then, you should be under source control anyway.

ASP.NET MVC - Missing "Convert to Web Application" option

I created a new MVC project and added some webforms pages to it in an effort to start adding new pages to my app using MVC and eventually port the old pages over as well. Everything is building and working correctly but I did notice that I don't have the "Convert to Web Application" option when right clicking an aspx file. And I think its not regenerating my designer files when I change the controls on a page.
My guess is that the ProjectTypeGuid is wrong or in the wrong order. Can someone confirm?
Old (Webforms) project file
<ProjectGuid>{4F95C3D9-228E-4BD5-9840-46224BA3EBA7}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
New (MVC) project file
<ProjectGuid>{A4690D3F-695B-4BF4-93B7-EA5B17793051}</ProjectGuid>
<ProjectTypeGuids>{603c0e0b-db56-11dc-be95-000d561079b0};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
This is so wrong on so many levels but I am going to answer you anyways in the hopes I might get an uptick or something. You have two routes with this. First route which I use all the time is put your mvc applications in their own projects. When your deploying the site drop the webforms application first, and then make a folder in that webforms application and put your mvc application into that folder. That should work like a charm for you. If you insit on having webforms and MVC Framework in the same project, then don't drop your webforms into the view folder. Create its own folder because you can not directly access your aspx pages from the views folder without making modifications to the web.config. Hope this helps.
MVC is available as a Web Project only. The VS2005 style Web Site is not supported.

Resources