Put ASP.NET MVC application in subdirectory of main MVC application?

十年热恋 提交于 2019-12-22 04:56:06

问题


I have my main website's application on my server at C:\inetpub\wwwroot, which I can view at http://www.mysite.com

I've created another separate MVC web application, named Subdir. I'd like to set it up so that if I visit http://www.mysite.com/Subdir, it will run my Subdir app.

What do I need to do for that? I obviously can't just drop the app in C:\inetpub\wwwroot\mysite.webui\whatever. Do I need to put the application in a certain directory? Do I need to configure anything in IIS?


回答1:


Yes you can drop the application in a subfolder of your original applicaiton, but the important thing is how you set up IIS for this new application. I suggest using sibling/parallel folders as a best practice.

  1. Deploy your applications in a sibling folder:

    c:\inetpub\wwwroot\ is your main app

    c:\inetpub\mynewapp\ for your secondary application.

  2. In IIS, expand your existing website and add a new Application, pointing the root folder to c:\inetpub\mynewapp\

Result:

http://mysite = c:\inetpub\wwwroot\

http://mysite/mynewapp/ = c:\inetpub\mynewapp

You're all good, and this is a pretty accepted "best practice" as you can tighten down NTFS and App Pool Identities easier now. Look up information on these topics and you'll be a step ahead of the game with your sites deployed this way.




回答2:


I obviously can't just drop the app in C:\inetpub\wwwroot\mysite.webui\whatever

Incorrect.
You need to do exactly that.

Just mark that directory as an Application in IIS manager and you're good to go.



来源:https://stackoverflow.com/questions/8584288/put-asp-net-mvc-application-in-subdirectory-of-main-mvc-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!