• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 773
  • Last Modified:

asp.net request url getleftpart problem - not adding forward slash

The code below constructs a url for a password reset method something like this

www.testwebsite.com/testapp/VerifyUser.aspx?Verify=34343r3e

It works fine locally but on the dev server

it does not add a forward slash before the verifyuser.aspx?

www.testwebsite.com/testappVerifyUser.aspx?Verify=34343r3e

I have tried every combination even hard coding the slash in but it will not add it.
I am sure it is to do with the way the IIS virtual is set - but I have not access to it

Can anyone help?
string baseURL = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;                                    
            string verifyUrl = "VerifyUser.aspx?Verify=" + VerinID.ToString();
            VeriURL = baseURL + verifyUrl;

Open in new window

0
mugsey
Asked:
mugsey
  • 4
  • 3
1 Solution
 
Roshan DavisCommented:
try this
string baseURL = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;                                    
baseURL = baseURL.Trim();
if(baseURL[baseURL.Length - 1] != '/')
{
	baseURL += "//";
}
string verifyUrl = "VerifyUser.aspx?Verify=" + VerinID.ToString();
VeriURL = baseURL + verifyUrl;

Open in new window

0
 
mugseyAuthor Commented:
ok thanks I cannot try until tomorrow but if it it works locally and if the same code that I have used before works OK with a normal IIS setup then do you think it must be the IIS setup?

The url on the stage box is like this

http://publictest.devbox34.com:8080/testapp/

0
 
Roshan DavisCommented:
must be some setup, but safer side is making sure that slash is present or not (like I kept the slash in the above code)
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
mugseyAuthor Commented:
ok thanks

Previously even if I have hard coded the slash in - it is still not present in the URL - so if I do

string verifyUrl = "/VerifyUser.aspx?Verify="fdf

the slash is taken out when it sends the URL in the email body
0
 
Roshan DavisCommented:
you may need to give 2 slashes in a string to display
eg.
string verifyUrl = "//VerifyUser.aspx?Verify="

or have to use @

eg.
string verifyUrl = @"/VerifyUser.aspx?Verify="
0
 
Roshan DavisCommented:
sorry my bad, plz ignore my previous comment, it is only for \
0
 
mugseyAuthor Commented:
ok i will try tomorrow and let you know friend
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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