I have a website that was originally written in webforms to which I have added MVC functionality. When debugging locally it works fine, however, once published and uploaded to my host the routes do not work and return a 404.
I am pretty sure that I have uploaded all the correct files. Would just appear that routing is not working.
Any idea?!
(the site will still serve normal aspx pages fine)
I think the problem may be related to Mixing ASP.NET MVC into ASP.NET WebForms
But I cant see from that thread what the solution was. It looks like it might be something to do with the app_pool mode - but I am running in integrated mode, which is right AFAIK
UPDATE 2
So I think I have routing working. I basically created a new MVC app and went through theweb config file line by line and made sure I have everything I needed. Funnily, none of the tutorials online mention the correct additions you need to make. hey ho..
I have have another issue mind you...
When i load my mvc page I am greeted with the message:
The SessionStateTempDataProvider requires SessionState to be enabled.
I've added a line to web.config to enable sessions (wasn't aware they were off) and it still doesnt work.
UPDATE
I created a new asp.net MVC project and ended up going through web.config line by line and ensuring that everything that related to MVC was included in my hybrid app. Suffice to say that none of the guides mention all the settings that are required (i was using the book professional asp.net mvc 1.0). I then included the global.asax file which is not published and set up a route so that a request for / was not being caught by MVC. I also had to enable sessions in web.config.
And now it works!
Should I mark this question as the answer...not sure on the protocol here :)
I was going through the same thing because I deploy with compiled views. I don't know why but global.asax isn't included in the Release folder that I uploaded. I just figured it was compiled into one of the DLLs. I was getting 404 for everything so I tried uploading global.asax and the site came to life.
Related
Alright I am a bit of a newb when it comes to ASP.net. I am used to PHP.
Anyway, I am working on a website that is connected to my server via ftp. Everything is working fine, except I just added some classes in the App_Code folder. I cannot access those classes when I go to the page on the web.
I was researching a bit and everyone said I needed to publish the website. Well I did that, and it completely broke. I had to restore from a backup and lost a lot. My own fault though.
The classes work if I am using them on a local web site, but not on the web. Any guidance here? I've tried moving the App_Code folder around with no luck.
the web server doesnt directly execute a .cs file like a .php file. a web server has registered handlers associated with a file extension. when a request arrives, the extension of the file is used to find a dll to process the request. the asp.net web pages model is an easy onramp for people coming from php. http://www.asp.net/web-pages
I have a hybrid ASP.NET/MVC 2 application that is currently hosted on II6.
I need to migrate this to IIS 7.5 and I'm having trouble getting it to work.
The furthest I've got is when the app pool is in integration mode, I migrated the web.congig using AppCmd.exe but only the MVC part worked and the .aspx pages wouldn't load.
I suspect that this is due to a custom handler that somone wrote called StaticFileHandler.
I know that this code is being hit as I see it in the log file.
And also checking the IISLogs I can see that the request returns a 200 http code
I've search around for answers but the only one I found that came close was someone who had their .aspx pages working and not their MVC part.
Has anyone got an idea what I can try?
I've been looking into this for days and havn't come up anything.
Thanks in advance.
I figured this out.
The issue was due to modules in the website.
These were doing things like compression and such, once taken them out, and removing them from the web.config, I got it working rather easily.
I copied my app and put it somewhere else. Then I changed IIS to look at the new place and ran it. Debugging it - it runs through my Controllers in the new location fine. But when it nips off to get the view it goes to the old location of my app?!?
Have you changed anything in your Routes? The Routing engine is what grabs your views when the controller requests them. Perhaps your issue is in your global.asax file? I'm afraid that's all I can offer, without more information.
I used .NET Reflector to work out how the route engine works. Turns out it kind of caches the route. It wouldn't listen to me until I restarted IIS, renamed the old directory so it didn't exist anymore and stopped my devenv.exe process. Then finally it was sorted
Someone has asked me to look at their code to do a few little changes to the processing, but before I can get anywhere, I can't even run up the main page. It seems to be MVC, seems to have the right routes etc. It defaults to a ~/home from default.aspx and there seems to be a route in place, but I get a 404.
I've tried changing the route and it still fails. I've debugged and it seems to be setting the routes up. I've set up Phil Haack's debug utility but it still just gives me a 404.
I'm quite new to asp.net MVC, but I've done asp.net and know some MVC (CakePHP) and I'm not really working with the MVC, just some processing code. Are there any big "gotchas" I should be looking for?
There is a Default.ASPX page that is included in the root path by default in all ASP.NET MVC projects. It has a comment in it that says:
Please do not delete this file. It is
used to ensure that ASP.NET MVC is
activated by IIS when a user makes a
"/" request to the server.
You might want to check and see if it is still there.
Are you running the app on IIS 6? If so, the problem is that IIS only invokes ASP.NET when it sees a .aspx extension in the URL. This can be fixed in a number of ways, described, for instance, here and here. I solved the problem changing IIS options to use aspnet_isapi.dll for all files (that is, *).
The problem was that the project was built on asp.net MVC Preview, and I already had asp.net MVC v1 installed, which seemed to create some sort of conflict.
I've removed asp.net MVC and the problem has gone away.
We configured IIS 5 by mappping * to asp.net handler so that ASP.NET MVC works. After configuring this, directory browsing is not working.
Also uploadify jquery plugin is not working. Showing IO error 2038.
Can someone please suggest us how to enable directory browsig with ASP.NET MVC configurations on IIS 5?
I don't think that you'll be able to get directory browsing to work with ASP.NET MVC in the same application. When you added the wildcard mapping, you told ASP to handle every request. If the request doesn't map to an actual file, it will try to match a route in MVC. If there isn't a matching controller with an index (assuming that's your default) action, then it will fail.
My suggestion is to split your web site into "application" and "content". Set up the application as a separate web site and apply the wildcard mapping there. Leave your content with the original configuration. I don't use IIS5 any more -- with one exception on an old XP development box -- I'm afraid that can't really be of more help.
If I were you, though, I'd upgrade to a more recent OS and web server. Expecting new technology to work on a decade-old platform is very optimistic.