Click here to Skip to main content
15,911,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have hosted mvc 5 application in iis,

Razor
@{Html.RenderAction("Index", "Document", new { area = "DocumentsManagement", controlObjID = 9 });}


This link above works fine in local and renders as http://localhost:1552:/DocumentsManagement/Document/Index.


But when browsed from iis, it will have to be http://localhost/Publish/DocumentsManagement/Document/Index

where Publish is the application folder or virtual directory.
Because of this new level "Publish", the application doesnt work fine in iis.

But this works fine in local

Please Suggest.
Posted
Updated 2-Dec-15 22:24pm
v3

1 solution

If your site doesn't work in a virtual directory (the technical name for what you're describing) then you haven't coded it properly. You are probably constructing your own urls rather than getting the framework to construct them for you, eg you have code like;

<a href="/Account/Login">Login</a>


instead of

<a href="@Url.Action("Login", "Account")">Login</a>


If you code correctly your site will work.
 
Share this answer
 
Comments
goshan2011 3-Dec-15 4:59am    
I am coding correctly only (like the 2nd way suggested by you), but still there is a path problem....To host in iis, i have converted the folders under wwwroot as the application, by selecting "Convert to Application" option...This is correct only rt?
F-ES Sitecore 3-Dec-15 5:01am    
If you create an application rather than a virtual directory then you'll get rid of the prefix. However your site should still work in a virtual directory, so if it isn't you're doing something wrong that you should probably fix. You haven't explained what the actual problem is.
goshan2011 3-Dec-15 5:09am    
I have a dashboard controller which can be browsed using this url when hosted on iis : http://locahost/Publish/DashboardArea/MyDashboard/Index
where 'Publish' is the application folder created under wwwroot.

This page uses another controller :: /ChartArea/Chart/Index

browser is looking for : http://localhost/ChartArea/Chart/Index
and gives 404 - it seems in iis, it is at this path : http://localhost/Publish/ChartArea/Chart/Index. Currently i am using Html.RenderAction for this, if with out this if i can use like ../ChartArea/Chart/Index, then my main controller would be able to track the child controller correctly.Please suggest
F-ES Sitecore 3-Dec-15 5:20am    
Whatever is creating the /ChartArea/Chart/Index probably hasn't been coded correctly.
goshan2011 3-Dec-15 5:47am    
Ok, the main problem is with the api calls , i am calling the api url like this url: "api/ChartsAPI/" + '@Model.ID.ToString()',
Is this correct or should it be "/api/ChartsAPI/" ?? Please help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900