Solved

HttpServerUtility issue

Posted on 2004-08-03
4
437 Views
Last Modified: 2008-01-09
Hello,

so I have webmatrix installed on my c:\ on my computer. I have a directory called employees, in which all my files are stored.
What I want to do is send an email to an account with a link to a .aspx file that contains an accountid for an employee.

Now when I just use the physical path on my harddrive i.e. c:\employees\confirm.aspx?id=asdfadsfdaa
The source code of the page opens and the page isn't served. I think this is becasue the file is not getting processed on IIS...

So I decided to use Server.MapPath...however I am writing this email send function in a custom class.

I am using the following string to acquire the path of my confirm.aspx file...

 string linkstring = HttpContext.Current.Server.MapPath("confirm.aspx?id=" + accountid);

This throws the following error:

System.ArgumentException: Illegal characters in path.

The accountid variable I am passing is simply a string of characters.....

what am I doing wrong? should I use Server.UrlPath instead if I am going to be using the website on http web?

thanks
0
Comment
Question by:simsingh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Assisted Solution

by:DotNetLover_Baan
DotNetLover_Baan earned 200 total points
ID: 11711914
Hi there,
Server.MapPath(),  will give the physical address of that file. It will not give the URL for that file.
http://msdn.microsoft.com/library/en-us/iissdk/iis/ref_vbom_serommp.asp

I guess here you have to build the URL string, by yourself.

Dim linkstring = "http://www.YourWebSite.com/confirm.aspx?id=" + accountid

then send it through the mail.

** provided the "confirm.aspx" file must be inside the folder that Serverver.Mappath() indicates. I mean your Default website directory in IIS.

-Baan
0
 
LVL 15

Accepted Solution

by:
Thogek earned 300 total points
ID: 11712108
Assuming that you're trying to resolve to a URL format....

Try
    string linkstring = HttpContext.Current.Server.MapPath("confirm.aspx") + "?id=" + accountid;

Or, better:
    string linkstring = HttpContext.Current.Server.MapPath("confirm.aspx") + "?id=" + HttpContext.Current.Server.UrlEncode(accountid);

More about the MapPath() method at http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebhttpserverutilityclassmappathtopic.asp
0
 
LVL 15

Expert Comment

by:Thogek
ID: 11712123
Er... that should have said, "Assuming that you're trying to resolve to a local file path format..."

If you're trying to resolve to a linkable URL, Baan has the right idea above.  Or, something like
  string linkstring = "/confirm.aspx?id=" + accountid;
or
  string linkstring = "/confirm.aspx?id=" + HttpContext.Current.Server.UrlEncode(accountid);
might do just as well (assuming confirm.aspx is in the root directory of the IIS Web site in question -- otherwise, just modify the path above accordingly).
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11712137
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question