Get extra path of URL of accessed WebForm

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.

著者
iPentec Document 編集部
iPentec Document 編集部です。
快適な生活のための情報、価値のある体験やレビューを提供します。
最終更新日: 2017-07-29
作成日: 2011-10-21
iPentec all rights reserverd.