Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 854
  • Last Modified:

response.redirect in asp.net 3.5

I have migrated an asp.net 1. project to visual studio 2008 now asp.net 3.5.  All corrections have been made and the project work except for one issue.  I have a form that spans 4 asp.net pages.  When a user complete page one (add_equipment_1.aspx) they click the submit button.

Response.Redirect("add_equipment_2.aspx?q1=" & MyInventoryID) is called which is the next page of the form.  This solution worked in my 1.0 application.

Since upgrading to asp.net 3.5 the code fails to send the user to the add_equipment_2.aspx page.  

The error message I recieve from the application is:

the error description is as follows : System.Web.HttpException: The file '/sellers/add_equipment/add_equipment.aspx' does not exist.

This is not the page I reference in my response.redirect.  Why is the app failing to send them to the correct page (add_equipment_2.aspx)
0
cannase
Asked:
cannase
  • 5
  • 5
1 Solution
 
Kevin CrossChief Technology OfficerCommented:
I believe it is starting it from the root of the application, you can force it to start from your current location by using :
Response.Redirect("./add_equipment_2.aspx?q1=" & MyInventoryID)

IIRC, this should get it for you, otherwise, you can use the Request.Url to get starting url and build this page relative to that.  The Url property returns an object of type System.Uri.  Here are the members of System.Uri for your reference:
http://msdn.microsoft.com/en-us/library/system.uri_members.aspx
0
 
cannaseAuthor Commented:
I will try the ./
Please consider the following:  "add_equipment/add_equipment.aspx' does not exist."

add_equipment.aspx is not even in my project??? it is the wrong name altogether?
0
 
Kevin CrossChief Technology OfficerCommented:
Ah, I see now.  I didn't catch the name part, was looking at path in front of it and thought it was looking for right file under wrong folder.  Is there any URL Rewriting or redirection in place that is possibly pointing to the wrong file?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
cannaseAuthor Commented:
Here is the code - I hope this helps.  It has worked for years until this update to 2008 and asp.net 3.5


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Session("GroupID") = "" Then
            Response.Redirect("../right.aspx")
        End If
        Dim MyInventoryID As String = ""
        Dim connection As New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("MasterConnection"))
        Dim command As New SqlCommand("SP_SE_New_Inventory_Step1a", connection)
        command.CommandType = CommandType.StoredProcedure
        command.Parameters.Add("@q1", SqlDbType.VarChar).Value = DropDownList1.SelectedItem.Value
        command.Parameters.Add("@q2", SqlDbType.VarChar).Value = Session.SessionID
        command.Parameters.Add("@q3", SqlDbType.VarChar).Value = Date.Today
        command.Parameters.Add("@q4", SqlDbType.VarChar).Value = Session("GroupID")
        connection.Open()
 
        Dim reader As SqlDataReader = command.ExecuteReader()
        While reader.Read
            MyInventoryID = reader("InventoryID")
        End While
 
        reader.Close()
        connection.Close()
 
        Response.Redirect("add_equipment_2.aspx?q1=" & MyInventoryID)
    End Sub

Open in new window

0
 
Kevin CrossChief Technology OfficerCommented:
That all looks straight forward.  I would check the target file to see if it has a redirect/include of the file in question.
0
 
cannaseAuthor Commented:
This is the result when adding ./
The error description is as follows : System.Web.HttpException: The file '/sellers/add_equipment/add_equipment.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)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
   at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
   at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
   at System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
   at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
   at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Open in new window

0
 
Kevin CrossChief Technology OfficerCommented:
Do you have a Http Handler doing rewriting or something in your Web.Config mapping URLs?  Just seems like you have something else going on other than the code being displayed.
0
 
cannaseAuthor Commented:
This is in my webconfig - not sure if this is the issue?
<httpHandlers>
			<remove verb="*" path="*.asmx"/>
			<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
		</httpHandlers>

Open in new window

0
 
cannaseAuthor Commented:
I just found this in my aspx file on add_equipment_1.aspx.  I am sorry to have put you through this.  The conversion process must have added this line

<form id="Form1" action="add_equipment.aspx" method="post" encType="multipart/form-data" runat="server">
0
 
Kevin CrossChief Technology OfficerCommented:
No worries.  Figured that had to be coming from somewhere different since was whole different file name.  :) Glad you found it.  
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now