我怎样才能prevent同源存取政策,MVC4和的WebAPI项目?政策、项目、prevent、WebAPI

2023-09-04 03:59:43 作者:哥的生活叫逍遥°

我也问过类似的问题,但我终于来到了我的问题的根源。我在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

 
精彩推荐
图片推荐