asp.net mvc 2 web application inside a Web site? - asp.net

I have a Asp.Net Web Site deployed as a WebSite inside IIS 7.5.
http://localhost/WebSite
Then I have a second Asp.Net MVC 2 web application which is deployed as Sub Application inside the above WebSite. So the mvc aplication should work on the following Url.
http://localhost/WebSite/MvcApp/
The web site works fine but when I browse the mvc Url http://localhost/WebSite/MvcApp/
It gives following error.
HTTP Error 403.14 - Forbidden The Web
server is configured to not list the
contents of this directory.
UPDATE: I have got this working. The issue was that I was missing the Web.Config inside the Views folder in the Asp.Net MVC 2 application.

You might need to create a virtual directory for the ASP.NET MVC application which will be associated to its dedicated application pool.

I know I had the same problem some time ago. In my case the two applications ran a siblings, not one inside the other. The problem was the web.config in the root directory (above the two sites) conflicting with the the web.config in the seperate sites. I solved it by just deleting the root web.config (since I have nothing running in the root.
So my advice (I know it's definately not a solution) is to check for conflicts in your web.configs.

Is you Asp.Net MVC site running ASP.NET 4.0? If so, make sure the app pool for that MVC site is setup asp ASP.NET 4.0 and not ASP.NET 2.0.

From within IIS Manager, you can right click any folder in the tree to be converted to an application. Have you tried it?

It sounds to me like the mvc routing module is not executing on your requests. You might want to check to make sure that not only is the web.config in your base web application not loading a module to supersede the routing handler, but that the web.config for your mvc application is handling routing properly. Take a look at this article for a rundown of the dependencies for routing and how it is configured internally within iis.

Related

Deploy MVC Website as an application into MVC website

I have an MVC web application deployed at the root of IIS but I have another MVC website application that needs to be deployed under the root web application.
I tried to add the child web application via 'Add Application' under website at the root but it is unable to read web.config of the inner application and giving some assembly errors that are included in the inner web application.
Please provide me procedure how I can deploy MVC web application under the MVC website. I hope the snapshot will clear the question.
I copied assemblies in the parent site that were being used by the child web application and it then worked.
One more solution seems possible, if the child web application routes are ignored by parent site. Though I haven't tried it.

MVC 3 on IIS 7 returns 404 for MVC extensionless url requests

Our website is a mix of asp.net web-forms and MVC 3. The website is developed in web-forms, except for a separate MVC application that is stored in a separate Directory in the root of the website and having its own web.config. The web-forms pages (aspx) are served properly by the IIS 7 server, but MVC url's are returning 404 - File or directory not found.
For example, say the website is www.abc.com and the MVC application is accessed using www.abc.com/aaa/controller/action, where aaa is the root directory for the MVC application and contains its own web.config. The web-forms url (say www.abc.com/feedback.aspx) is working but, the MVC URL's (say (www.abc.com/aaa/Controller/Action) are returning 404.
I have confirmed from my shared hosting provider, that the website is running over .net 4 Integrated pipeline Mode application pool, so extensionless url's should be handled by the IsapiModule by default, without requiring any extra configuration for the same.
One doubt that crops in my mind is whether the MVC application root folder (aaa in above example) should be converted to a separate application ?
Any guesses, to resolve the above MVC url issue?
The hosting provider uses WebsitePanel , through which I was able to create a Virtual Directory for the folder containing the MVC application. The MVC URL's are now being routed to the Isapi handler and not returning 404(file not found) any more. So, I guess I will close this topic here.
In short, creating a virtual directory for the MVC application resolved the issue.
asp.net-mvc and webforms share the routing system. You should make a Hybrid WebApp, part WebForm and MVC. I did something similar recently here, where the webforms is the main app and the MVC is the nested one. In this case, you must have only one global.asax and a single web.config for the entire site. The MVC could live at the same directory as the WebForm, but only with they share stuff.
I followed this guide from Scott Hanselman to make this work.

ASP.NET 3.5 website under an ASP.NET MVC 3 application - getting Do not have permission error

So I'm rewriting an application that was an ASP.NET 3.5 website. There is a folder that has ASHX handlers. These handlers are APIs called by external apps. My solution is to run this API folder under the new MVC site as an 3.5 application. The URLs stay the same and everything will work wonderfully.
In the MVC app, I have forms authentication enabled in the web.config. I IgnoreRoute the API folder in Global.asax.cs. I created a new app pool for .NET 2.0 and assigned it to the new app created on the API folder.
Accessing the handler from the server works, I get my custom error as I did not specify my credentials. Accessing the handler from my machine, I get You do not have permission to view this directory or page. I created a default.aspx page in the API folder and the page displays. So it's a handler (ASHX) issue.
I ended up creating a new web site solution targeting .NET 3.5 and had only 1 handler Test.ashx that returned Hello World. Configured IIS to use a different app pool (classic mode) for the API folder and it worked. So I added in my existing handlers and it worked. I'm guessing something in the web.config file was causing the issue.
Try going to IIS and under your website -> Handler Mappings.
Check whether .ashx is mapped.

Is it possible to host an asp.net MVC in the same folder as asp.net web forms app?

I have a domain and a hosting account and I'd like to in a folder host an MVC app and in another host asp.net web forms app.
Is it possible?
Yes, ASP.NET web forms and ASP.NET MVC applications can reside side-by-side in the same application. I have that in my current application and it works fine. You just have to make sure that your classic ASP.NET application paths don't conflict with your ASP.NET MVC routes -- seems that the MVC routing handler wins out. I've run into that a few times.
Here's a good article that walks through hosting web forms and MVC side-by-side.
As others have said, this is most certainly possible. You'll likely want to modify your MVC routes to ignore requests for aspx or axd resources:
routes.IgnoreRoute("{resource}.aspx");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Yes, it is possible. You can also have different web.config files for each folder. Of course, it depends on the hosting .NET version, if you can use MVC..
You can also have your single hosting host multiple domains, or make a subdomain and host the legacy site there.
This article shows in details how to do this: http://www.hanselman.com/blog/IntegratingASPNETMVC3IntoExistingUpgradedASPNET4WebFormsApplications.aspx

IIS 5 & ASP.NET MVC Directory Browsing Problem

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.

Resources