简体   繁体   English

本地运行的Azure移动服务(点网后端)引发未授权错误

[英]Azure Mobile service (dot net backend) running locally, throws unauthorized error

I've created a fresh new Dot Net backend based Azure Mobile service, downloaded it, published the service part to azure with publish settings. 我已经创建了一个新的基于Dot Net后端的新Azure移动服务,下载了该服务,并通过发布设置将服务部分发布为天蓝色。 This all works fine. 这一切都很好。

(this is the default to do app that Azure Mobile service generates, no changes made it to it.) (这是Azure移动服务生成的默认做应用程序,未对其进行任何更改。)

Now for development & debugging purpose I need to connect with my local service. 现在出于开发和调试的目的,我需要连接本地服务。 Following is what I've done 以下是我所做的

  1. Updated "applicationhost.config" IIS express file to have a new binding type 更新了IIS Express文件“ applicationhost.config”以具有新的绑定类型

where 192.168.2.6 is my local internal IP 192.168.2.6是我的本地内部IP

  1. Run VS 2013 in Admin mode. 在管理员模式下运行VS 2013。
  2. Set both project as startup project from solution 将两个项目都设置为解决方案中的启动项目
  3. Updated following code in App.Xaml.cs 更新了App.Xaml.cs中的以下代码

    public static MobileServiceClient MobileService = new MobileServiceClient( "http:// 192.168.2.6:59984/" ); 公共静态MobileServiceClient MobileService = new MobileServiceClient(“ http:// 192.168.2.6:59984/”);

  4. Run

  5. Browser opens to show the service running & WP8 emulator starts loading the app. 浏览器打开,显示正在运行的服务,并且WP8仿真器开始加载应用程序。

This is what happens I can see the service up & live on localhost:59984, I can also see in IIS Express toolbar icon that http:// 192.168.2.6:59984 is also running the local service just fine. 这就是发生的情况,我可以在本地主机上启动并运行该服务:59984,也可以在IIS Express工具栏图标中看到http:// 192.168.2.6:59984也可以正常运行本地服务。 Click open it & it shows the default "Service Up & Running" page 单击打开它并显示默认的“服务启动和运行”页面

The WP8 emulator starts, Application Loads & I get a "The request could not be completed. (unauthorized)" error. WP8仿真器启动,应用程序加载,我收到“请求无法完成。(未经授权)”错误。

Please check the image below 请检查下面的图片

在此处输入图片说明

I've also run a ntash command to allow IIS express for remote connections. 我还运行了ntash命令,以允许IIS Express进行远程连接。 as mentioned in This Blog 本博客所述

can someone please help? 有人可以帮忙吗? I've been struggling with this for over 2 days now & what seems like a very simple thing, is driving me nuts now. 我已经为此苦苦挣扎超过2天了,看起来很简单的事情现在让我发疯了。

Thanks Supreet Tare 感谢Supreet皮重

我需要的只是Visual Studio 2013 Update 2,一切正常。

Take a look at this article. 看一下这篇文章。

You need to specify the application key of the service in the Web.config file: 您需要在Web.config文件中指定服务的应用程序密钥:

<add key="MS_ApplicationKey" value="Overriden by portal settings" />

If you run the service within Visual Studio, you don't need these values, and every request will pass. 如果在Visual Studio中运行该服务,则不需要这些值,并且每个请求都会通过。 When you deploy the service on Azure, these values are overriden with the correct values. 在Azure上部署服务时,这些值将被正确的值覆盖。 But, if you deploy the Mobile Service on your local IIS, you need to manually set them, and be sure that they match the values you enter in the client. 但是,如果将移动服务部署在本地IIS上,则需要手动设置它们,并确保它们与您在客户端中输入的值匹配。

After changing the MS_ApplicationKey value in the web.config and also updating my phone client app to specify the application key in the MobileServiceClient constructor, I was able to hit the service from the phone! 在更改了web.config中的MS_ApplicationKey值并更新了我的电话客户端应用程序以在MobileServiceClient构造函数中指定应用程序密钥之后,我能够从电话中找到该服务!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM