我怎样才能prevent同源存取政策,MVC4和的WebAPI项目? [英] How can I prevent the same-origin-access-policy with MVC4 and WebAPI projects?

查看:179
本文介绍了我怎样才能prevent同源存取政策,MVC4和的WebAPI项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也问过类似的问题,但我终于来到了我的问题的根源。我在VS 2010的解决方案有两个项目。其中一个项目是一个MVC 4应用程序,使一个REST调用到第二的WebAPI项目,现在即使这些项目都在同一个解决方案,我在使用的任何IE之外获得同源策略错误我相信这是同一个事实,即每个项目都被一个单独的开发服务器实例启动,但我不知道。

I have asked similar questions before but I have finally come to the root of my problem. I have a solution in VS 2010 with two projects. One project is an mvc 4 application that makes a rest call to the second WebAPI project, now even though these projects are in the same solution I get a same-origin policy error when using anything other than I.E. I believe this has to do with the fact that each project gets launched on a separate dev server instance but I am not sure.

有人可以解释一个解决方案给我,我可以兼得,而不会遇到相同的原始错误运行这些项目? (相关方的问题,如果我想我的API暴露给公众使用怎么会有人使用它没有得到同样的错误?)

Can someone please explain a solution to me where I can have both of these projects running without encountering the same origin error? (Related side question, if I ever wanted to expose my api to public use how would anyone use it without getting the same error?)

推荐答案

我最终什么了做什么工作对我来说,现在正在使用IIS防爆preSS和指向该项目,以相同的虚拟目录

What I ended up doing and what worked for me, for now is using IIS Express and pointing the projects to the same virtual directory

这篇关于我怎样才能prevent同源存取政策,MVC4和的WebAPI项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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