IIS虚拟目录会创建路径问题 [英] IIS Virtual directory creates path problem

查看:311
本文介绍了IIS虚拟目录会创建路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS 2013和MVC5

要在IIS中托管应用程序,我使用了Properties-> Web - >服务器 - >本地IIS并单击Create Virtual目录。

因此,这为MyPortal创建了一个VD



但是现在我遇到了路径问题。



我的应用程序中有一个api控制器。

当我使用VS开发服务器时它是使用url访问:http:// localhost:1553 / api / menuapi并且数据被正确访问。



但是一旦它被托管到IIS,它停止工作。

选中后,它正在尝试从url中获取数据,即:

http:// localhost / api / menuapi,它会出现404错误。



但实际上api很好,数据可从网址访问:

http:// localhost / MyPortal / api / menuapi



为什么以及如何创建这个路径问题?

以下是我如何进行api通话:

1.在javascript文件中:

I am using VS 2013 and MVC5
To host the application in IIS, i have used Properties-> Web ->Servers ->Local IIS and clicked on Create Virtual directory.
So this created a VD for "MyPortal"

But now i have a path problem.

I have an api controller in my application.
When i was using VS development server it was being accessed using the url : http://localhost:1553/api/menuapi and the data was getting accessed correctly.

But once it is hosted to IIS, it stopped working.
When checked, it is trying to fetch the data from url i.e :
http://localhost/api/menuapi and it gives a 404 error.

But actually the api is fine and the data is accessible from the url :
http://localhost/MyPortal/api/menuapi

Why and how is this path problem created?
The below is how i am doing the api call :
1. In javascript file :

$http.get('/api/menuapi/' + menuid).success(function (data) {});



请建议是否有其他选择。


Please suggest if any alternatives.

推荐答案

http.get(' / api / menuapi /' + menuid).success( function (data){}) ;
http.get('/api/menuapi/' + menuid).success(function (data) {});



请建议是否有其他选择。


Please suggest if any alternatives.


这篇关于IIS虚拟目录会创建路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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