I want to use Response.Write() in VB.NET to redirect to relative Url. I am using the following code:
EDIT:
Response.Write(("account/msgbox.aspx?action=account&status=" & Convert.ToInt16(eAccountStatus).ToString))
Response.Write(("~/account/msgbox.aspx?action=account&status=" & Convert.ToInt16(eAccountStatus).ToString))
and
Response.Write(("/account/msgbox.aspx?action=account&status=" & Convert.ToInt16(eAccountStatus).ToString))
return the same in my case.
My application error event handler reports that the url being formed is invalid.
Here is what i am getting:
http://localhost:14154/~/http:/localhost:14154/account/msgbox.aspx?action=account&status=6
instead of this
http:/localhost:14154/account/msgbox.aspx?action=account&status=6
Response.Clear() before Response.Write() does nothing.
I cannot use/switch to Response.Redirect() now before the whole project uses Response.Write() and choosing to use Response.Redirect() will render all code useless that is written after Response.Write calls.
I just need clear the base url that is being appended somehow. Please let me know how may i achieve this.
Thanks you.
P.S: This code was working fine previously. Some developer made a change and now the Response.Write() is NOT causing the redirects as described above.
EDIT
Stack Trace:
System.Web.HttpException (0x80004005): The file '/~/account/msgbox.aspx' does not exist.
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
::1
Details:
http:// localhost:14154/~/account/msgbox.aspx?action=account&status=6