Website Design/Css Minor Error

Discussion in 'HTML & Website Design' started by akshaykalia, Apr 7, 2011.

  1. #1
    akshaykalia, Apr 7, 2011 IP
  2. style0

    style0 Peon

    Messages:
    108
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    what is the method of changing url's?
    Seems to me that the css file just isn't there.
     
    style0, Apr 7, 2011 IP
  3. akshaykalia

    akshaykalia Member

    Messages:
    77
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #3
    Hi,
    Thanks for reply
    Well, i am making the site in ASP .NEt using C#
    So in Global.asax file, i did the follow :



    protected void Application_BeginRequest(object sender, EventArgs e)
    {
    // If the requested file exists
    if (File.Exists(Request.PhysicalPath))
    {
    // Do nothing here, just serve the file
    }
    // If the file does not exist then
    else if (!File.Exists(Request.PhysicalPath))
    {
    // Get the URL requested by the user
    string sRequestedURL = Request.Path.Replace(".aspx", "");


    // Highlights

    if(sRequestedURL.Contains("-")==true)
    {
    int n = Convert.ToInt32(sRequestedURL.IndexOf("-"));
    int m;

    for (int i = n; ; i--)
    {
    if (Convert.ToChar(sRequestedURL) == '/')
    {
    m = i;
    break;
    }
    }

    string sTargetURL = "~/VideoGallery.aspx?id=" + sRequestedURL.Substring(m + 1, n - m - 1);
    Context.RewritePath(sTargetURL, false);
    }

    //New Address

    if (sRequestedURL.IndexOf("/Highlights/") != -1)
    {
    int n = Convert.ToInt32(sRequestedURL.LastIndexOf("/"));
    int m;
    n--;

    for (int i = n; ; i--)
    {
    if (Convert.ToChar(sRequestedURL) == '/')
    {
    m = i;
    break;
    }
    }

    string sTargetURL = "~/VideoGallery1.aspx?id=" + sRequestedURL.Substring(m + 1, n - m);
    Context.RewritePath(sTargetURL, false);
    }


    // Owing to RewritePath, the user will see requested URL in the
    // address bar
    // The second argument should be false, to keep your references
    // to images, css files


    // ###### I M P O R T A N T ######
    // To enable postback in ShowContents.aspx page you should have following
    // line in it's Page_Load() event. You will need to import System.IO.
    // Context.RewritePath(Path.GetFileName(Request.RawUrl), false);
    }
     
    akshaykalia, Apr 7, 2011 IP
  4. style0

    style0 Peon

    Messages:
    108
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you need to put in the starting slash in the path to your css, favicon and js files in your html head.

    Right now it looks like:
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    And you need it to look like:
    <link href="/css/style.css" rel="stylesheet" type="text/css" />

    See the starting slash that starts the href url?

    This will need to be done for all head links, the js files css files and favicons
     
    style0, Apr 8, 2011 IP
  5. akshaykalia

    akshaykalia Member

    Messages:
    77
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #5
    O thanks a lot
    It solved it
    Cant believe i missed it
    Anyways, Have a nice day
     
    akshaykalia, Apr 8, 2011 IP