Saturday, March 31, 2012

The ASPX name

Hi,

Inside an .aspx code, what would be the reliable way to know what is the
..aspx page file name on IIS?

Thanks,
Ali> Inside an .aspx code, what would be the reliable way to know what is the
> .aspx page file name on IIS?

Request.ServerVariables["SCRIPT_NAME"] would return the base name. You can
combine it with Request.ServerVariables["SERVER_NAME"] and a "http://"
prefix to get the full url.

This is C#, you should replace brackets with parentheses for VB.
Here's another:

string myPath = Page.Request.Path;
string pageName = myPath.Substring(myPath.LastIndexOf('/') + 1);

Michael Earls

"A.M" <IHateSpam@dotnet.itags.org.sapm123.com> wrote in message
news:uhiYpoB5DHA.3848@dotnet.itags.org.TK2MSFTNGP11.phx.gbl...
> Hi,
> Inside an .aspx code, what would be the reliable way to know what is the
> .aspx page file name on IIS?
> Thanks,
> Ali
>> Inside an .aspx code, what would be the reliable way to know what is the
>> .aspx page file name on IIS?

> string myPath = Page.Request.Path;
> string pageName = myPath.Substring(myPath.LastIndexOf('/') + 1);

That would actually be the pretty way, I gave you the old and ugly way.

Martin.

0 comments:

Post a Comment