[C#] Get extra path of URL of accessed WebForm
Tag:[C#] [ASP.NET]
In ASP.NET, you want to get extra path of URL which accessed WebForm.

Example of extra path

For
http://app.ipentec.com/webapp/imageeditor/edit.aspx

If you access the URL below.
http://app.ipentec.com/webapp/imageeditor/edit.aspx/add/bitmap

/add/bitmap
is extra path.

How to get extra path

Use PathInfo property in HttpRequest class to get extra path.

Example code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebAppPathDemo
{
  public partial class WebForm : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      Literal1.Text = "";
      Literal1.Text += string.Format("Request.PathInfo: {0:s}<br/>", Request.PathInfo);
    }
  }
}

Execution result

http://app.ipentec.com/webapp/imageeditor/default.aspx/draw/bitmap Visit the above URL.
Request.PathInfo: /draw/bitmap
appears on the screen.

Register date :2011-10-21    Last update :2017-01-17
Tag:[C#] [ASP.NET]
JapaneseEnglish
プライバシー    iPentecについて
iPentec all rights reserverd. (ISDC)