如何发布MVC应用程序与代理,如果Azure不使用相同的web.config作为我的本地环境 [英] How to publish MVC app with proxy if Azure does not use same web.config as my local environment

查看:195
本文介绍了如何发布MVC应用程序与代理,如果Azure不使用相同的web.config作为我的本地环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的MVC的Web应用程序,一个控制器功能(验证)调用的服务。请参见下面code和注意MessageHandlerClient在Visual Studio生成一个服务代理。服务代理调用client.ValidateMessage(formdataasbson [HLmessage]。的ToString())在我的本地开发环境工作正常。当我发布项目天青,调用验证控制器功能不再起作用。怀疑与代理的一个问题,我改变了验证()来回馈硬codeD的结果,重新发布到Azure以及一切工作正常 - 确认在Azure中的Web服务代理行为的问题。

In my MVC web app, one controller function (Validate) calls a service. See below code and note that MessageHandlerClient is a service proxy generated in Visual Studio. The service proxy call client.ValidateMessage(formdataasbson["HLmessage"].ToString()) works fine in my local dev environment. When I publish the project to Azure, calls to Validate controller function no longer work. Suspecting a problem with the proxy, I changed Validate() to give back hard-coded results, re-publish to Azure, and all works fine - confirming a problem with the web service proxy behavior in Azure.

  [HttpPost]
    public ActionResult Validate(String serializedformdata)
    {
        try
        {
            BsonDocument formdataasbson = this.serializer.JSONFormtoBSON(serializedformdata);    
            MessageHandlerClient client = new MessageHandlerClient();
            this.jsonresponse.ReturnValue = "true";

            StandaloneValidator.My_ServiceReference.Error[] results = client.ValidateMessage(formdataasbson["HLmessage"].ToString());       

            this.jsonresponse.ReturnMessage = results.ToJson();

            return Json(this.jsonresponse);
        }
        catch (Exception ex)
        {
            this.jsonresponse.ReturnValue = "false";
            this.jsonresponse.ReturnMessage = ex.Message;
            return Json(this.jsonresponse);

        }

    }

更重要的是,我看到下面我本地的web.config文件的Web服务代理的详细信息(IP故意遮挡):

What's more, I see details of the web service proxy in my local web.config file as below (IP intentionally obscured):


      
    

我已阅读关于Azure的web.config文件和事实,即它不是写不同的岗位,所以我怀疑我的地方.....代理的信息是从来没有发表在Azure上。如果确实web.config中并没有公布从地方到Azure的,然后我明白了为什么我的代理不起作用。现在的问题是.....我应该做些什么来解决?!

I have read various posts about web.config in Azure and the fact that it is not writable, so I'm suspecting my local ..... proxy info is never published in Azure. If indeed web.config does not publish from local to Azure, then I understand why my proxy doesn't work. The question is.....what should I do to fix??!

编辑:我看到各种帖子来自web.config中csfg文件Azure的讨论中的一些设置迁移 - 也许是一个可行的解决方案?由于我不是编码这些设置手动读取(我只是创造了从URL服务服务代理)我担心自动生成code或服务的任何下,引擎罩的行为,不知道如何阅读从csfg迁移的设置。

I see various posts discussing migration of some settings from web.config to csfg files for Azure - perhaps a viable solution? Given that I am not coding manual read of these settings (I simply created service proxy from URL to service) I worry about auto-generated code or any "under-the-hood" behavior of the service not knowing how to read migrated settings from csfg.

推荐答案

根据你有什么上面写的,看来你是混淆Web角色和Web站点。首先你需要了解这两者之间的区别,所以你可以什么为您的应用选择更好的决定。下面是一些有用的链接:

Based on what you have written above, it seems you are confused with Web Role and Web Sites. First you would need to understand the difference between these two so you can make better decision on what to choose for your application. Here are some useful links:

  • SO discussion on difference between Azure Web Sites and Web Role
  • MSDN Article on when and why to choose Azure Web Sites and Web Role and Azure VM

Windows Azure的网站,您没有对IIS Web服务器的完全控制,并因为一些设置网站的具体设置是可配置的,有些不是。在Windows Azure的网站,大部分的设备和系统的具体设置加入到web.config中都被覆盖,所以这些设置不起作用。你也不能RDP到您的Azure网站的实例为好。

Windows Azure Web site, you do not have full control over IIS web server and because of that some of the settings web site specific settings are configurable and others are not. In Windows Azure websites, most of machine and system specific settings added into web.config are overwritten so these settings does not work. Also you can not RDP to your Azure Websites instance as well.

如果你必须使用ASP.NET MVC应用程序,它必然需要代理服务器配置,则必须将其部署到的 Windows Azure云服务

If you have to use ASP.NET MVC application which MUST need proxy configuration, you must deploy it to Windows Azure Cloud Service.

这篇关于如何发布MVC应用程序与代理,如果Azure不使用相同的web.config作为我的本地环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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