我在Windows Azure上部署了我的MVC-3应用程序.但现在,当我通过staging url它请求它时,显示我(抱歉,处理您的请求时出错).现在我想看到完整的错误消息,默认情况下它隐藏了一些安全原因.我知道我们可以通过web.config文件执行此操作.但是怎么样?
我在Azure上有一个MVC网站.我已经编写了一个控制器动作来代替一个资源,它应该返回HTTP 404,但是正文内容应该是一些HTML,我在那里解释了404的原因.这是作为一个标准动作来实现的Response.StatusCode.这在本地工作正常,但是当部署到Azure时,我没有获得我的自定义视图,而只是纯文本中的错误消息.我<customErrors>在Azure上删除了调试,结果相同.
这是部署到Azure时收到的原始响应:
HTTP/1.1 404 Not Found
Cache-Control: private
Content-Length: 103
Content-Type: text/html
Server: Microsoft-IIS/8.0
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By: ARR/2.5
X-Powered-By: ASP.NET
Date: Sat, 17 Aug 2013 17:24:19 GMT
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Run Code Online (Sandbox Code Playgroud)
同样重要的是,如果我删除服务于此的路由,我会得到一个标准的.NET 404错误页面,所以我想我的自定义操作正在运行.行动很简单:
[HttpGet]
public ActionResult LegacyMedia(string originalUrl)
{
ViewBag.OriginalUrl = originalUrl;
return new ViewResult404() {ViewName = "LegacyMedia"};
}
public class ViewResult404 : ViewResult
{
public override void …Run Code Online (Sandbox Code Playgroud) 我正在尝试查看我网站的错误,当我访问该网站时,我收到此消息:
Server Error in '/' Application.
Runtime Error
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.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the …Run Code Online (Sandbox Code Playgroud) 我正在尝试做一些非常简单的事情,但遇到了一个我已经尝试了两天来修复的错误。我有一个简单的 ASP 按钮从代码隐藏调用函数(见下文)......我收到以下错误。但只有当我将站点上传到 Azure 时,它才能在模拟时正确运行。
SCRIPT5007: Unable to get property 'PRM_ServerError' of undefined or null reference
Run Code Online (Sandbox Code Playgroud)
MicrosoftAjaxWebForms.js,第 5 行字符 11118
ASP 按钮定义如下,没什么特别的...
<asp:Button CausesValidation="false" ID="Button1" runat="server" Text="Login" OnClick="radbtn_loginButton_Click" />
Run Code Online (Sandbox Code Playgroud)
再次背后的代码......疯狂的简单......
protected void radbtn_loginButton_Click(object sender, EventArgs args)
{
try
{
string uName;
string uPass;
uName=UsernameBox.Value;
uPass=PasswordBox.Value;
if(uName=="admin" && uPass=="password")
{
Response.Redirect("dsxHome.aspx");
}
else
{
loginMessage.Text="Login Invalid!";
}//end if
}
catch
{
loginMessage.Text="Problem with Login";
}
}
Run Code Online (Sandbox Code Playgroud)
消息标签嵌套在 AjaxPanel 中……我正在站点中其他页面的其他地方执行其他 Ajax 调用……但最简单的一个正在中断……
任何想法......我知道我错过了一些愚蠢的事情......
迈克尔
出于某种原因,当我收到ASP.NET运行时错误时,它没有加载我的自定义错误页面
<customErrors mode="On" defaultRedirect="app_offline.htm" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="app_offline.htm"/>
<error statusCode="500" redirect="app_offline.htm"/>
</customErrors>
Run Code Online (Sandbox Code Playgroud)
那是在我的web.config中.
我仍然得到这个,但它没有加载我的错误.htm页面:
Server Error in '/' Application.
Runtime Error
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.
Details: To enable the details of this specific error message to be viewable on remote machines, …Run Code Online (Sandbox Code Playgroud)