2013-01-14 69 views
0

因此,最终我将我的MVC应用程序发布到Azure云服务。我的数据库也在那里。在将WindowsAzure项目添加到我的解决方案并将我的2个项目(模型和Web)添加为角色后,我可以在本地运行该应用程序。无法看到Azure云服务中的应用程序错误

但是当我运行的URL,我得到错误:

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

所以我设置并重新发布,但我仍然得到同样的错误

我需要强制Azure的告诉我发生了什么和揭示错误,任何人有任何想法?

http://bizoptcloudservice01.cloudapp.net

+0

你说你设置 ...在你的网页配置中? –

+0

是啊,那就是为什么我现在打这个砖墙。我发布了cloudService项目,其中包含我的Web项目作为角色。但我现在想知道如何检查整个解决方案,包括我的web.config。我猜如果我能以某种方式查看真正的错误信息是什么,Azure云服务中是否存在日志,我已经通过所有菜单在线看不到任何东西 – John

回答

2

没有没有内置到Azure云服务日志。你可以实现你自己的,但涉及到一些实现。在我的解决方案中,我创建了一个自定义错误页面。我的web配置看起来像这样:

<customErrors mode="On" defaultRedirect="~/error/Error"> 
... 
</customErrors> 

我有一个名为“Error.cshtml”我查看/共享目录视图。使用上面的配置,只要我的应用程序出现错误,就会显示它。

@model System.Web.Mvc.HandleErrorInfo 

@{ 
    ViewBag.Title = "Error"; 
} 

<h2> Sorry, an error occurred while processing your request!!?!</h2> 

<div> 
    Try again. If the problem persists... 
    Close all your browser windows and re-login to the application. If the problem still persists... 
    Contact the service desk with the details of this error. 
</div> 

     <h3>Error Details</h3> 
     <div> 
     <strong> 
     @Model.Exception.Message 
     </strong> 
      <pre>@Model.Exception.StackTrace</pre> 
    </div> 
    </div> 
</div> 

同样为了上面的工作,您需要将其添加到您的Global.ascx.cs中。它在出现错误时定义应用程序的默认行为。像这样:

public static void RegisterGlobalFilters(GlobalFilterCollection filters) 
    { 
     filters.Add(new HandleErrorAttribute()); 
    } 

Here is a blog post that talks about it in some more details.

该职位,这问题的答案也进入记录错误。如果你想要去的,应该让这条路线供您参考:

Setting HTTP Status in ASP.NET MVC controller results does not render view

+0

谢谢,非常错误的东西,当我实现这个我只是得到同样的错误,没有什么变化没有办法,我可以告诉发生了什么事在那里在azure服务,令人沮丧 – John

+0

你还有filters.Add(new HandleErrorAttribute());在Global.RegisterGlobalFilters? –

+0

我没有在Global.RegisterGlobalFilters中设置任何东西,我应该怎么做?我需要强制Azure显示错误消息。自定义错误设置为关闭在Azure中没有任何区别。让我觉得它好像web.config不能被看到或使用别的东西。当它说成功发布似乎有其他人可以做 – John

1

检查,你没有覆盖你的web.config与自动MVC项目transforms.The的Visual Studio 2012的模板设置添加此行该web.config.release文件:

当应用发布你的web.config可能正在改变。

编辑:此外,您可能想看看ELMAH,这是一个伟大的日志记录工具,很容易添加到您的项目,将让你看到每个错误而丢失信息的:

+0

如何停止在web配置的发布版本中添加此行? – Kyle

+0

你有一个web.release.config文件吗? – amhed

相关问题