ASP.net 3.5 Masterpages and HTTP Module

Discussion in 'C#' started by deltron, Jan 5, 2009.

  1. #1
    Hey all,

    So I'm designing a site that uses a Masterpage for the design as well as an HTTP module for SEO purposes.

    My http module uses a Context.Rewrite to redirect all requests to the SEO friendly urls to either the product or category page: something like this...

    If pageFileName.Split("/").Count() = 6 Then
    context.RewritePath("../ShowProd.aspx?ID=" & pageFileName.Split("/")(5).Replace(".html", "") & "&cat=" & pageFileName.Split("/")(4))
    ElseIf pageFileName.Split("/").Count() = 5 Then
    context.RewritePath("ShowProd.aspx?ID=" & pageFileName.Split("/")(4).Replace(".html", "") & "&cat=" & pageFileName.Split("/")(3))

    etc... etc...

    Everything works great in terms of it retrieving the right variables from the URL and rerouting the user to the correct page. However, the problem occurs when I try and go to pages beyond the root.

    If I go to www.example.com/sample.html... then the masterpage shows up fine, if I go to www.example.com/folder/sample.html, then the page works, but the masterpage is not visible.

    My masterpage is set as follows:

    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="ShowCat.aspx.vb" Inherits="ShowCat" title="Untitled Page" %>

    Has anyone else ever encountered this? any help would be really appreciated. I thought the ~ meant it went straight to the root. Am I wrong?
     
    deltron, Jan 5, 2009 IP
  2. deltron

    deltron Active Member

    Messages:
    397
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    73
    #2
    figured out my own question guys.. It was finding the masterpage, it was the styles sheet that wasn't showing up. I am using a very cheap solution, and there must be a better one. I just put:

    <link REL="StyleSheet" href="../../../Style.css" TYPE="text/css" MEDIA="screen" />
    <link REL="StyleSheet" href="../../Style.css" TYPE="text/css" MEDIA="screen" />
    <link REL="StyleSheet" href="../Style.css" TYPE="text/css" MEDIA="screen" />
    <link REL="StyleSheet" href="Style.css" TYPE="text/css" MEDIA="screen" />

    This way it always finds one, and the rest are ignored. any better way around this?
     
    deltron, Jan 5, 2009 IP
  3. vihutuo

    vihutuo Well-Known Member

    Messages:
    1,511
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #3
    Are you using themes?
     
    vihutuo, Jan 9, 2009 IP