server.transfer

T

Tlink

I am using server.transfer from within vb.net, which is called from asp.net
I find that I can move to correct page the first time the server.transfer is
executed but all subsequent attempts cause a error message. The following is
my logic code:

If RedirectPage.StartsWith("~") Then

RedirectPage = Replace(RedirectPage, "~", "")

Dim bs As New Uri(CurrentUrl)

(Currenturl = http://testiis/project18/admin/user/edit.aspx)

TString = baseur & RedirectPage

(base url = http://testiis/project18/)

(redirect page = "cleanup.aspx"

Dim urinew As New Uri(TString)

RedirectPage = bs.MakeRelative(urinew)

End If



Server.Transfer(RedirectPage, True)



I am unsure of what I am doing wrong ?
 
K

Kevin Yu [MSFT]

Hi Tlink,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you use Server.Transfer to
redirect a page, the first time it succeeds but the subsequent attemps
failed. If there is any misunderstanding, please feel free to let me know.

As far as I know, Server.Transfer can only be used within the same web
application. Could you please confirm this? Also, I see the redirect page
was make relative, I suggest you try to step through the code to see what
the value of RedirectPage is when the Transfer call fails. Is there
anything wrong with the RedirectPage argument?

If that still doesn't work, could you let me know when it fails, the value
of RedirectPage and the error message?

Thanks!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
T

Tlink

I have converted this into a function on a page, and make it available to
all other pages by placing it in a Module with the following code

Public PublicMoveControl As New MoveControl

It is now reporting the following error continuously:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

Line 310: End If
Line 311:
Line 312: Server.Transfer(RedirectPage, True)



This is now happening on the first run I am testing on a windows XP PRo will
all patches up-to-date.


Kevin Yu said:
Hi Tlink,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you use Server.Transfer to
redirect a page, the first time it succeeds but the subsequent attemps
failed. If there is any misunderstanding, please feel free to let me know. Yes that is correct

As far as I know, Server.Transfer can only be used within the same web
application. Could you please confirm this? Also, I see the redirect page
was make relative, I suggest you try to step through the code to see what
the value of RedirectPage is when the Transfer call fails. Is there
anything wrong with the RedirectPage argument?
the argument contains "..
No I have placed the exact values in the above code for you
 
T

Tlink

After rebooting my system the following error values:

redirectpage = "../../cleanup.aspx"

Resulting in the following error message:

Failed to map the path '/project18/cleanup.aspx'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Failed to map the path
'/project18/cleanup.aspx'.

Source Error:

Line 310: End If
Line 311:
Line 312: Server.Transfer(RedirectPage, True)
Line 313:
Line 314: 'Try
 
K

Kevin Yu [MSFT]

Hi Tlink,

Could you let me know if the page you're redirecting to is in the same
application as the original one? Because I see redirectpage =
"../../cleanup.aspx", that might be in another application. In this case I
suggest you try to use a fixed (hard-coded) URL as the redirectpage to see
if it is the url's problem or the Server.Transfer's problem.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Y

Yuan Ren[MSFT]

Hi Tlink,

At the current stage, I think there is some reason cause the application
can not mapping the file correctly. Base on my experience, I suggest we
hard code the ULR using absolute path format of ¡°cleanup.aspx¡±, then just
call ¡°Server.Transfer¡± method and check whether our application can work
well. If the application still caught some error, please send to me some
more detail information of call stack so that help us find the way of
resolving.



Additionally, some situation like the account of running the application
has no right of accessing the file can cause this issue. So please make
sure the account (¡°aspnet¡± for IIS5 and ¡°IIS_WPG¡± for IIS6) is
available for accessing the resource.



By the way, have you still caught ¡°NullReferenceException¡± in the
application? If it still exists, I recommend we can set a new breakpoint
for ¡°Server.Transfer¡± method and start to debug the current application.
In watch window under debugging, we can watch the value of the ¡
°RedirectPage¡± variable and make sure whether it is null or not.



I appreciate your understanding and hope the above information helps, if
you have any issues or concerns please let me know. I will be happy to be
of further assistance.



Yuan Ren[MSFT]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top