title: SEO friendly URl in asp.net
body: <p>Im creating a web application. There are a default page where a list of questions. When user click the question that will redirect to the user to ViewQuestion that is in the Question folder. At the default.aspx page im using the datalist control to display question title . And there i am generating the url with id to the question . For this code is below .</p>
  
  <pre><code> protected void listQuestion_ItemDataBound(object sender, DataListItemEventArgs e)
      {
          if (e.Item.ItemType == ListItemType.Item ||
                   e.Item.ItemType == ListItemType.AlternatingItem)
          {
              LinkButton lnkTitle = (LinkButton)e.Item.FindControl("lnkQuestion");
              // lnkTitle.Style.Add("text-decoration", "none");
              PostEntity Item = (PostEntity)e.Item.DataItem;
              lnkTitle.PostBackUrl = GenerateURL(Item.Title, Item.Id);
          }
      }
  
      public static string GenerateURL(string title, int Id)
      {
          string strTitle = title.Trim();
          strTitle = strTitle.ToLower();
          //strTitle = strTitle.Replace();
          strTitle = strTitle.Replace(" ", "-");
          strTitle = strTitle.Trim();
          strTitle = strTitle.Trim('-');
          strTitle = "~/Questions/ViewQuestion.aspx?QuestionID=" + Id.ToString().Trim() + "/" + strTitle + ".aspx";
  
          return strTitle;
      }
  </code></pre>
  
  <p>in global.asax the code is </p>
  
  <pre><code>void Application_Start(object sender, EventArgs e)
      {
          // Code that runs on application startup
  
          RegisterRoute(RouteTable.Routes);
  
      }
  
      static void RegisterRoute(RouteCollection route)
      {
          route.MapPageRoute("Default", "Default", "~/Default.aspx");
          route.MapPageRoute("ViewQuestion", "Questions/ViewQuestion{QuestionID}", "~/Questions/ViewQuestion.aspx");
      }
  </code></pre>
  
  <p>And the viewpage to get the Querystring as below :</p>
  
  <pre><code>lblQustionText.Text = this.Page.RouteData.Values["QuestionID"].ToString() as string; // giving me object reference exception 
  </code></pre>
  
  <p>my pageurl is generating like this </p>
  
  <pre><code>/Questions/ViewQuestion.aspx?QuestionID=1376/get-the-current-logged.aspx
  </code></pre>
  
  <p>How can i make this example for SEO friendly url . Thanks for your answer.</p>