Visual Studio 2010 .NET Framework 4.0を使用するC#の場合。
を使用してリダイレクトを行おうとすると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");
}
}