Solved

HttpServerUtility issue

Posted on 2004-08-03
4
420 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
  • 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now