asp.net mvc 映射路由
问候, 我在 mvc 应用程序中遇到链接问题。当我通过 Visual Studio 运行它时,一切正常。那么链接如下: http://localhost:2566/ActivateClient/Activate/6543e2d6-707d- 44ae-94eb-a75d27ea0d07
当我通过IIS7运行它时,链接如下: http://localhost/ActivationService/ActivateClient/Activate/6543e2d6-707d- 44ae-94eb-a75d27ea0d07
默认路由如下:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
我假设我必须更改此MapRoute,对吗?如何改变呢? ActivationService 是我在 IIS 中的虚拟目录。有人可以帮我解决这个问题吗? 我也尝试按如下方式映射路线:
routes.MapRoute(
"Default", // Route name
"ActivationService/{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
但也没有成功
Greetings,
I have a problem with link in mvc application. When I run it via Visual Studio it's ok. The link then is as follows:
http://localhost:2566/ActivateClient/Activate/6543e2d6-707d-44ae-94eb-a75d27ea0d07
when I run it via IIS7 the link is as follows:
http://localhost/ActivationService/ActivateClient/Activate/6543e2d6-707d-44ae-94eb-a75d27ea0d07
The default route is as follows:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
I assume I have to change this MapRoute, am I right? How to change it? ActivationService is my virtualDirectory in IIS. Can someone help me with this please?
I also tried to maproute as follows:
routes.MapRoute(
"Default", // Route name
"ActivationService/{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
but also without success
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否添加了新的或替换了现有的?
如果添加了,则需要将其放置在现有的之前。
规则优先..
Did you add the new one or replace the existing one?
If you added, you need to position it before the existing one.
The rules take precedence..