我试图通过混合ASP.Net MVC4和AngularJS来创建模块化应用程序。 MVC所做的是它允许我们像下面那样进行路径分离。
主屏http://127.0.0.1:81/
当用户登录时,我为他们提供如下的基本路径
`http://127.0.0.1:81/shipper/#/operations/home`要么
`http://127.0.0.1:81/client/#/orders/home`所以我得到了每种类型用户的基本屏幕模板,从那时起,它就是一个SPA,它接管模板,有时根据需要共享一个公共视图。
现在我遇到的问题是,当我必须引用任何服务器对象,如Web服务器上的图像,它们都位于root\themes\images\image1.jpg
fiddler中的图像URI已解析为http://127.0.0.1:81/client/themes/images/image1.jpg
代替
http://127.0.0.1:81/themes/images/image1.jpg
这显然意味着这将失败。
我的HTML如下所示:
<img class="media-object" src="themes/images/img180x120.png" />
有没有办法可以覆盖它以强制它忽略路径中的/ shipper / / client?
此致,Kiran
I am trying to create a modular applications by mixing the ASP.Net MVC4 and AngularJS. what MVC does is that it allows us to have a path separation like below.
Home screen http://127.0.0.1:81/
when a user logs in, i provide them with a base path as below
`http://127.0.0.1:81/shipper/#/operations/home`or
`http://127.0.0.1:81/client/#/orders/home`so I get a base screen template per type of user and from then on it is a SPA that takes over on the template which sometimes share a common view based om the need.
now the issue i am having is that when i have to reference any server object like image on the web server that are all located in the root\themes\images\image1.jpg
the image URI in the fiddler is getting resolved to http://127.0.0.1:81/client/themes/images/image1.jpg
instead of
http://127.0.0.1:81/themes/images/image1.jpg
which obviously means this will fail.
my HTML looks like below:
<img class="media-object" src="themes/images/img180x120.png" />
is there a way I can override this to force it to ignore the /shipper or /client from the path ?
Regards, Kiran
最满意答案
事实证明,在url之前,使用/将使其成为相对于主机服务器的路径。
As i turns out just preceeding the url with a / will make it a path relative the the host server.
更多推荐
发布评论