asp.net mvc - nested site deployment - asp.net-mvc-3

How do I enforce an asp.net mvc application to point to the subfolder instead of root folder.
Lets say I have website called: http://mywebsite
I have got totally different asp.net mvc applications called UserApp and CustomerApp. There is no common thing between them. Now, I want to deploy the application like:
http://mywebsite/UserApp/SomeController/SomeAction
http://mywebsite/CustomerApp/SomeController/SomeAction
I deployed the application above ways. But, after deployment, only home page works. Any other nested controller/action still points to root path instead of specific path.

You probably need to set both subfolders as applications in IIS.

The answer from Slaks is not enough, as default MVC routing is "/controller/action" from the web root.
You could use the IIS routing module to rewrite paths so that http://yourWebSite/UserApp/SomeController/SomeAction is rewrited to http://yourWebSite:8080/SomeController/SomeAction and setup 2 websites on different ports internally.
Or you could modify mvc route mapping. It could work, ... or not. Search for "MapRoute" in MSDN.
Or you could create 2 websites with 2 different hosts.
This is not unusual for 2 unrelated websites :=)

Related

3 MVC projects in 1 Solution

I have to build 3 MVC web applications using Entity Framework (www.company1.com www.company2.com www.company3.com). The websites will all access the same sql server database, but will be slightly different in their own way (appearance, data etc). More than likely all three MVC applications will be hosted on the same server, but binded to different domain names.
Currently in Visual Studio, I have the following structure to my solution
Domain Classes
Data Layer
Services
Repositories
MVC App 1
MVC App 2
MVC App 3
I would have preferred to have used Area's, but I can't because each site has to be assigned it's own different domain name. I guess I am just seeking assurances that architecting my solution this way won't cause any difficulties for me when the applications are published. I am slightly paranoid about the sites sharing the dbContext or something, however, I know that many sound silly.
It would be great if anyone could advice me if this all looks ok, or maybe there is a better way to do what I am asking.
Thanks as ever.
I've done the same thing for the same reason. I have a CMS that must reside at a different host-name. It works fine.
The trick is finding ways of sharing code across the MVC apps. To avoid circular dependencies and such, I created one more MVC app to hold things such as my controller that serves up image files, HTML Helpers that can be re-used, etc.
As long as you have a good way of validating and differentiating the sites in the Datalayer, than you will not have to worry. How are you validating this?
I also would always put simulair code and pages in a main project so you do not copy parts or even whole pages for different sites. (My guess is that you already did so)

mvc application at mvc application

I wrote a simple web application on ASP.NET MVC3 (for example, app1). And I now want to write a simple CMS for it (for example, app2).
How can I access to folder app1/Content/ from app2, if app2 is an independed application?
In the future I want to copy app2 to one of the folders of app1 (for example, app2 path will be C:/app1/app2/)
Is this approach correct for building sites in ASP.NET MVC3? If not, please, recomend a better approach!
Sorry for my English.
You should use Area not a different project for simple usages. you can find more here
First of all, yes, it's not a very good design choice.
If you need some common stuff between the 2 applications, you can use several approaches, the simpliest that comes to my mind is to define in each application a variable in app settings (inside the web.config) pointing to a folder or URL containing the common stuff and use that.
Same thing if you need to use the same DB from more applications: just use the same connection string.
If you really need to make the 2 apps work together for some reasons, you should make one single app and a viable solution could be to split it using Areas.

MVC 3 Content and Relative Path is not working when deployed to IIS 7.5

I am developing a MVC 3 Web Application and just tried to deploy it on IIS 7.5
The page is shown, but all the images as well as url path is not working at all.
I search through a lot of sources and found out that it seems to be compulsory for a MVC application to have all path being enclosed in either:
#Url.Action
#Url.Content
#Html.Action
and so on. So I tend to change all my relative path by using those valid method.
I understand it should be a correct way to use all those valid mvc helpers, but I am just a beginner and this is my first web application. My question is:
Is it possible to use any method to "resolve" the relative path so that it can be found even after deployed?
Really need help here... thank you very much....
You are not correct that you need to use those helpers for all URLs. There is nothing to prevent you from outputting URLs 'manually', as literals, or as you have done above.
Something wonky has happened with the paths of the files on your server upon deployment, most likely.

How can I mix Forms Authentication and Windows Authentication in MVC 2 in IIS 7.5?

I've seen this posted alot that solves the problem if you are running ASP.Net application not a MVC 2 one in IIS 7.5. Would the same solution work using location in the web.config and 2 seperate login pages like it does for asp.net? Do you need to register a new route to do that?
I know it would work with 2 seperate applications in IIS, but i want them all in the same application. Any ideas?
Solutions for asp.net
http://mvolo.com/blogs/serverside/archive/2008/02/11/IIS-7.0-Two_2D00_Level-Authentication-with-Forms-Authentication-and-Windows-Authentication.aspx
Mixing Forms authentication with Windows authentication
http://craigandera.blogspot.com/2004/07/mixing-forms-and-windows-authentication_24.html
It looks like you can use the following solution.
http://mvolo.com/blogs/serverside/archive/2008/02/11/IIS-7.0-Two_2D00_Level-Authentication-with-Forms-Authentication-and-Windows-Authentication.aspx
But i had to create a ASP.net page inside my MVC solution that gets hit directly to handle the Windows Authentication then redirects to the mvc site. The location section inside of the web.config should work then since it's not relying on the routing.

Is it Possible to publish two Websites, one in JSP and another in ASP.net with same domain name?

I want to publish two different websites one in JSP and another in ASP.net with same domain name because I am working on asp.net site and i want to add some features of jsp so i will design these features in jsp.
With proper configuration of your server you could probably send requests to either one app or the other. You'd also have to consider how sessions are supposed to be shared between the applications etc.
I'd probably add some base-url to both applications, and use this to make the server redirect the request to the correct app:
ASP.NET app: your.domain.com/asp/
J2EE app: your.domain.com/j2ee/
Have a rewrite-cond on the asp/j2ee parts and do what you'd normally do to serve the request.

Resources