在 C# 中使用 Visual Studio 2010 .NET Framework 4.0。
每次我尝试使用重定向时response.redirect("url")
都会收到以下错误:
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=App_Web_uck3gvsb
StackTrace:
at _Default.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\p1\Default.aspx.cs:line 15
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
这是代码:即使在没有任何东西的简单上,我也会遇到同样的错误!
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
public HttpResponse response;
protected void Page_Load(object sender, EventArgs e)
{
response.Redirect("http://www.google.com");
}
}