简体   繁体   中英

How to publish an ASP.NET MVC 4 project in a specific url

I'm in a situation that I do not know how and I do not know if it's possible to do.

I have a website in ASP.NET MVC, let's call kelvinsite.com.br, this site is a asp.net mvc project.

And I also have another site, we'll call kelvinproject.com.br, this site is another project aspnet mvc.

What I want to do is publish the site kelvinproject.com.br inside the project kelvinsite.com.br without merging the web projects in the same project in Visual Studio, I want both to stay separate in the same solution.

So the url would be:

http://kelvinsite.com.br/kelvinproject

Is it possible? What is the name of it?

It's possible, but there's some potential pitfalls depending on how you've defined your URLs. The term you're looking for is "sub site" and it usually requires some work in IIS. You could do something similar with ASP.NET MVC Areas, but you're not really packaging the apps separately in that case.

There's a pretty good discussion on subsites here: Sub-Website in IIS - ASP.NET

Basically, you deploy the app to a subfolder of the parent app on IIS. Configurations get carried down, which means you might have to change the web.config on the child to remove parent entries, etc, depending on things like .NET versions of each, etc.

You should be able to publish each site completely independently. There are only two major things to keep in mind on the server. 1) Make sure that the directory, kelvinproject, is marked as an application in IIS. 2) You may need to adjust the web.config in the main application so that it's settings aren't inherited by any child applications. You can easily do this using the element of the web.config. There's a good example of this at: Scott Hansleman's blog and it's pretty simple. Just put things like and within this location and it won't be inherited in the new application.

Don't think of them as a specific site. Each one is a sepeaate web application and technically they don't know anything about each other, and don't care about the other. You can have 50 projects in the same solution and it doesn't matter to any of them where the others are published.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM