locked
Default page urldata RRS feed

  • Question

  • User1916581254 posted

    Hi.

    How I can set up my site to get urldata from link for default page?

    site.com/default/1- this work, but

    site.com/1 return 404 error

    Saturday, August 15, 2015 2:04 PM

Answers

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 25, 2015 6:58 AM
  • User-1980594115 posted

    I think you are trying to link to a referring page. For example the original page (mainGrid.cshtml) is going to another (Default.cshtml):

    // Redirect User To Login Page
    Response.Redirect(@Href("~/Default.cshtml?loc=tables/mainGrid.cshtml"));
    

    Then you want to return back from the Default.cshtml page to the referring page (mainGrid.cshtml):

    var userpage = "";
    var loc = "";
    
    // Test For Referring URL Page Existence
    if (Request.QueryString["loc"] == null)
    {
    	loc = "";
    }
    	else
    {
    	loc = Request.QueryString["loc"];
    	userpage = "~/" + loc;
    }
    
    // Redirect User Back to Default (or page if no referring page provided) or Referring Page that exists
    if (loc == "") {
     // Redirect User Back to Default Page
     Response.Redirect(@Href("~/"));
    }
    else
    {
     // Redirect User Back to Referring Page
     Response.Redirect(@Href(userpage));
    }
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 25, 2015 3:05 PM

All replies

  • User325035487 posted

    in the default.cshtml file in the root

    var urldata1 = UrlData[0].IsEmpty() ? 0 : UrlData[0].AsInt(); //Assuming that's an integer
    
    var urldata1 = UrlData[0].IsEmpty() ? "" : UrlData[0].ToString(); //Assuming that's a string

    If you still have problem getting it. Better post your code so that some one can see whats going on

    Sunday, August 16, 2015 1:41 AM
  • User1916581254 posted

    Hi.

    Its only work when i'm write url like this site.com/default/1, but does not work when site.com/1.

    In web forms this work fine, but in web pages no.

    Tuesday, August 25, 2015 3:07 AM
  • User325035487 posted

    site.com/ loads the default.cshtml ???

     

    Tuesday, August 25, 2015 6:38 AM
  • User1916581254 posted

    site.com/ loads the default.cshtml ???

     

    yes

    Tuesday, August 25, 2015 6:50 AM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 25, 2015 6:58 AM
  • User1916581254 posted

     Not helped. One more example

    site.com/default.cshtml---open home page

    site.com/default/1----open home page with urldata

    site.com/1 ---- 404 error.

    How I can use urldata with default page, if url does not contain page name(default)

    Tuesday, August 25, 2015 8:14 AM
  • User325035487 posted

    Post your default page code here in full.. Cant help you unless we can see whats going on

    Tuesday, August 25, 2015 12:15 PM
  • User1313602441 posted
    Have you checked your web.config file to ensure your default site is actually "default.cshtml"?
    Tuesday, August 25, 2015 2:24 PM
  • User-1980594115 posted

    I think you are trying to link to a referring page. For example the original page (mainGrid.cshtml) is going to another (Default.cshtml):

    // Redirect User To Login Page
    Response.Redirect(@Href("~/Default.cshtml?loc=tables/mainGrid.cshtml"));
    

    Then you want to return back from the Default.cshtml page to the referring page (mainGrid.cshtml):

    var userpage = "";
    var loc = "";
    
    // Test For Referring URL Page Existence
    if (Request.QueryString["loc"] == null)
    {
    	loc = "";
    }
    	else
    {
    	loc = Request.QueryString["loc"];
    	userpage = "~/" + loc;
    }
    
    // Redirect User Back to Default (or page if no referring page provided) or Referring Page that exists
    if (loc == "") {
     // Redirect User Back to Default Page
     Response.Redirect(@Href("~/"));
    }
    else
    {
     // Redirect User Back to Referring Page
     Response.Redirect(@Href(userpage));
    }
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 25, 2015 3:05 PM