在IIS 8.x的虚拟目录角的应用程序有奇怪的网址的行为 [英] Angular app on IIS 8.x virtual directory has strange URL behavior

查看:245
本文介绍了在IIS 8.x的虚拟目录角的应用程序有奇怪的网址的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在与MVC IIS 8.x的角度与JS的问题。我与虚拟目录应用程序索引页,像这样:

I'm having a problem with Angular JS on IIS 8.x with MVC. My application index page with virtual directory is like so:

https://myapp.xyz/VirtualDirectory/

网页加载的角应用。我的角路由设置为:

That page loads the angular app. My angular routes are set up as:

$routeProvider
.when('/', {
    templateUrl: 'Content/Partials/Home/Index.html'
})
.when('/Error', {
    templateUrl: 'Content/Partials/Shared/Error.html'
})
.otherwise({
    redirectTo: '/Error'
});

所以,如果我访问的第一个环节,我的网址如下:

So, if I access the first link, my URL looks like:

https://myapp.xyz/VirtualDirectory/#/

这完美的作品,并解决我的谐音罚款。角请求谐音与它的虚拟目录,所以我看到一个HTTP请求:

This works perfectly and resolves my partials fine. Angular requests the partials with the virtual directory in it so I see an HTTP request to:

https://myapp.xyz/VirtualDirectory/Content/Partials/Home/Index.html

不过,如果我没有尾随斜线访问,如:

However, if I access without a trailing slash like:

https://myapp.xyz/VirtualDirectory

角路线:

https://myapp.xyz/VirtualDirectory#/

一旦发生这种情况,没有我的路线工作(他们不尊重虚拟目录)。他们的路线为:

Once this happens, none of my routes work (they do not respect the virtual directory). They route as:

https://myapp.xyz/Content/Partials/Home/Index.html

这打破了我所有的路线和模板在我的指令来定义的。如何解决这个问题有什么建议?

This breaks all of my routes and templates defined in my directives. Any suggestions on how to fix this issue?

推荐答案

尝试在你的头标记添加此。

try to add this in you head tag.

<html>
<head>
    <base href="/VirtualDirectory/">
</head>
<body>
    ...
</body>

这篇关于在IIS 8.x的虚拟目录角的应用程序有奇怪的网址的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆