In my development environment
在我的开发环境中
Url.Action("Index", "User") ---> /user
In production, the application is configured under a application named "ucms"
在生产中,应用程序在名为“ucms”的应用程序下配置
Url.Action("Index", "User") ---> /ucms/User
I have authorization based on the url i.e., /user, so it is failing in production environment. How do I fix this issue to remove ucms?
我有基于url即/ user的授权,因此它在生产环境中失败了。如何修复此问题以删除ucms?
Edit Routes are default one's. FYI, I've upgraded application from mvc 3.0 to 4.0.
编辑路线是默认路线。仅供参考,我已将应用程序从mvc 3.0升级到4.0。
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
Edit I have figured out one way to do it, could anyone share thoughts on this.
编辑我已经想出了一种方法,任何人都可以分享这方面的想法。
Store the virtual path in web.config.
将虚拟路径存储在web.config中。
<add key="appvirtualpath" value="~/ucms"/>
And while passing the url to the database layer, I would replace the virtual path will blank.
在将url传递给数据库层时,我会将虚拟路径替换为空白。
Url.Action("Index","User").Replace(ConfigurationManager.AppSettings["appvirtualpath"].ToString(), "~");
Url.Action(“索引”,“用户”)。替换(ConfigurationManager.AppSettings [“appvirtualpath”]。ToString(),“〜”);
1 个解决方案
#1
1
I solved this problem by adding a virtual path in development environment
我通过在开发环境中添加虚拟路径解决了这个问题
Right click on project, properties, web and then virtual path.
右键单击项目,属性,Web,然后单击虚拟路径。
I don't know if there is a way to configure it in the production environment
我不知道是否有办法在生产环境中配置它
#1
1
I solved this problem by adding a virtual path in development environment
我通过在开发环境中添加虚拟路径解决了这个问题
Right click on project, properties, web and then virtual path.
右键单击项目,属性,Web,然后单击虚拟路径。
I don't know if there is a way to configure it in the production environment
我不知道是否有办法在生产环境中配置它