ASP MVC 2 with asp.net development server won't load default controller & action for an empty route - asp.net-mvc

This used to work fine, but recently it refuse to load the default page for an empty route, instead it lists directory contents.
for example
http://localhost:1234/ should take me to the same page as http://localhost:1234/Home/Index assuming global.asax hasn't been modified, however recently it just takes me to "Directory List -- /" and lists out the content of the project folder.
This is using the ASP.NET Development Server. The sites work fine when deployed into IIS on a server.
Does anybody have any ideas, this is really annoying!

I would check the project settings like suggested on this other question:
Launching my debug MVC3 application opens a specific .cshtml file in the browser

Through trial and error I've determined that this is caused by the IBM RTC plug-in, when disabled it works normally.
I find this very surprising, but I've double checked and it is definitely that!

Related

Razor views not generating html after deploying Umbraco 7.2 in IIS 7

I am new to Umbraco, so I started creating a site to play a bit with it. While I had my site running on IIS express (either from VS or WebMatrix) everything worked fine. After deploying the site to IIS 7, the razor views of the front end are display in plain text, meaning that I actually see Razor syntax in the browser. Umbraco back office is working perfect though, except when I hit preview, in that case I get the plain Razor syntax again. I then try to deploy a simple new MVC project to IIS and the Razor engine worked just fine, so I guess is not a problem in IIS but in Umbraco configuration. Is there any configuration tweak I need to take care in Umbraco configuration to solve this problem? Thanks in advance for the help.
I also tried to deploy it in the IIS of my local development machine (the same in which it runs OK in IIS-express) which has the right framework and everything and I got the same cshtml display in the browser.
After struggling a bit more with the problem I found the issue causing this behavior. After installing the starter kit a lot of files are generated in the folder and subfolders of the solution. In order to publish the solution to generate the contents of your website the VS project needs to have all these files included as project files. I found out that some views were excluded of the project and thus not being generated when publishing. I included the missing views and double check that all important files were part of the project and problem solved.

Going live with a MVC site

I just moved my site to my server which is windows 2003 sp2, sql 2005.
I have a mvc site running on my server (althought i have it turned off) it works fine but my new site does not work correctly
For some reason the routing fails to work on my server. I can hit the homepage fine using the domain but clicking on any link(or typing it in) results in simply a page not found issue!
"The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable."
MVC doesn't play so well with IIS6 out of the box. Have you configured a handler for either .mvc or a wildcard handler?
You need to make your MVC assemblies bin deployable: http://www.britishdeveloper.co.uk/2010/05/mvc2-deploy-could-not-load-file-or.html

Deploying MVC Application to Web Server doesn't run correctly

I have reading posts all night looking for an answer to my issue and haven't found anything that works for me yet. I am sure there is a simple way to do this but I haven't been able to discover it yet.
Details:
MVC 2 Preview
Asp.net 3.5 sp1 framework
VS 2008 C# web application
Windows Server 2008
IIS 7
I have the application running well through VS 2008 no problem. When I hit the play to run in debug mode it starts the ASP.NET Development Server the application loads fine and works as expected, great!
When I publish the application locally or to my web server both on IIS 7 the application doesn't run correctly. Some of the icons are missing and the google maps map is missing. When I view the source it appears correct at first glance, but I can see the paths to the images are looking for the MVC paths and it isn't finding them. It appears the app is running as a regular asp.net app and not an mvc app, maybe?
I also tried to just hit the full source code locally on localhost and the exact same issue is present.
So, I guess my question is how do I deploy a MVC application to run the same in IIS as it does through the development server.
PS The environments are clean and pretty much out of the box.
#user68137 is correct in saying that you need to use relative paths for the images.
I got caught out on this one too, and here's my previous SO question about it...
In short, you need to do something like this...
<img src='<%= Url.Content( "~/Content/Images/banner.jpg" ) %>' alt="Banner" />
Hope this helps!
I had the relative paths set, but what I didn't realize is when I deployed it to the server it went to wwwroot\subsite... I had the relative paths set to src="....\image.jpg" to get back to the root of the site. My error was that if the site is not in the root then the subsite drills back to the root to find the images and of course doesn't find them. Same thing was happening with the JS files. I used the Url.Content and it worked great! problem solved!
The interesting this is when running through the VS dev server with a subsite it still worked well and found the paths even though it shouldn't have. VS dev server <> IIS
Thanks for your help on this!
Simon.
Once you know the virtual path to the location you are deploying the project to, you should go into the project configuration in Visual Studio and add it to your project. This way the visual studio development server will use the same path structure as the deployment server. This will save you countless hours of work when deploying.
When you run your website through Visual Studio, every single request gets processed through the ASP.NET pipeline, including images, CSS and other resources. IIS by default only processes specific extensions (e.g., aspx) unless you tell it otherwise through configuration. Paths like '/content/images/yourimage.jpg' should work just fine...I suspect it's something amiss in your IIS configuration.
Another possibility which I've run into is any custom ISAPI filters you may have installed on the IIS server (e.g., ISAPI_rewrite). It's easy to set up rules in its configuration that lead to some very unexpected results.

404 Error when moving ASP.NET MVC app from IIS6 to IIS7

I just got a new development box and am having issues getting my MVC project up and running. My old box had Server 2003 and IIS6. I was able to get my MVC apps working on this box after setting up the wild card mapping as mentioned here. My new box is running Vista Business and IIS7. When I copied my app over and tried to run it, I get an 'http 404 The resource cannot be found.' error. However, if I create a new MVC app and run that, everything works fine. I also copied the Nerd Dinner app over from my old box and that works fine as well.
I've verified that the app is running in Integrated Mode and have compared the web.config files of the working and non-working apps but see nothing that is different other than application specific appsettings. I have tried to run the app in Classic Mode with the wild card mapping set, but that does not work either. I have also tried running the app using Cassini, but got the same results.
I have posted the answer on my blog, check it out at
http://nkitdugar.blogspot.com/2011/02/special-care-while-migrating-mvc.html
I had a MVC based application that was earlier hosted on IIS 6. Now IIS 6 doesn't support extensionless URL routes by default, so we need to add some extension to the controller name in the default route defined like {ControllerName}.aspx{Action method}{Id} in IIS6. Also we if we wanted to go for some other extensions like .mvc etc. then we needed to map it using techniques like wildcard mappngs etc.
Now when we have migrated to IIS7, then extensionless URLs are supported which means URLs can be there which don't have any corresponding physical location.
So when you are migrating your MVC application to IIS7 then make sure the default route define in Globla.asax don't have any extension defined with controller like {controller}.aspx\{action method}\{Id} and change it to \clean URL route {Controller}\{Action Method}\{ID(optional)}.
Second thing you should keep in mind that the pipeline mode of AppPool of the website should be set to Integrated from classic.
That's all now your website is ready to be hosted on IIS7.
OK, I figured out the problem. The App in question is a port of a Web Forms app over to MVC as a proof-of-concept project. As such, when the project was first created, we just added a .MVC to the end of the project name to make it {project name}.MVC. This, not surprisingly now that I know what's going on, caused a problem with the default routing definitions. I changed the name to use an underscore instead of a period and everything works now. I'm assuming that it worked fine while running under IIS6 since it was setup using a wild card mapping and therefore there was no .MVC extension to confuse it.

asp.net mvc - site works fine locally but not after deployment

i have an asp.net mvc website. http:/mywebsite.com (just for this example)
I have been testing this asp.net mvc website locally on my machine and everything works fine on my local machine during testing. When i deploy to my web server
when i bring up http://mywebsite.com it goes to HomeController and load the view Views/Home/Index.aspx (which is perfect). So the main default page is fine.
The issue is, if i click any other other links (again that all seem to work fine locally) i get the following error:
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
Please try the following:
* Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.
* If you reached this page by clicking a link, contact the Web site administrator to alert them that the link is incorrectly formatted.
* Click the Back button to try another link.
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)
some examples would be:
http:/mywebsite.com\Photos
http:/mywebsite.com\Links
there definitely are controllers and views setup for this (or it wouldn't work locally).
does anyone have any idea how this might work fine locally but somehow on the webserver it doesn't
Are you running the site on II7 in integrated mode? If not, you need to add a wildcard handler so that all URLs get mapped to your application. See Phil Haack's blog post on running ASP.NET MVC ON IIS 6.
Something else to watch out for. I had a static website - deployed on IIS 7.5. Added some MVC Controllers to handle some simple server side apps and then re-deployed it. I didn't copy the web.config file, because I wrongly assumed that everything that was needed was in the one that was automatically created by the server.
You must copy the web.config up as well.

Resources