RewritePath

Discussion in 'ASP .Net' started by Brad, Mar 28, 2005.

  1. Brad

    Brad Guest

    I'm attempting to rewrite urls, to point non-aspx pages to aspx page. The
    rewrite code works but once the Application_BeginRequest ends I get a
    NotSupported exception. Running this on win2003 server using 1.1 framework
    and I have mapped the non-aspx to the aspnet_isapi.dll.

    Brad


    Here is a test example of what I am doing.
    ===============================================
    Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
    System.EventArgs)

    Dim requestedURL As String =
    HttpContext.Current.Request.Url.AbsoluteUri.ToString
    Dim newURL As String = ""

    If requestedURL.ToLower.IndexOf(".ctx") > 0 Then
    newURL = requestedURL.Replace(".ctx", ".aspx")
    ElseIf requestedURL.ToLower.IndexOf(".htm") > 0 Then
    newURL = requestedURL.Replace(".htm", ".aspx")
    End If

    If newURL.Length > 0 Then
    HttpContext.Current.RewritePath(newURL)
    End If

    End Sub

    ===============================================
    Error message received when I try to browse to something like
    http://localhost/mytest/default.htm or http://localhost/mytest/default.ctx
    ===============================================
    The given path's format is not supported.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.NotSupportedException: The given path's format is
    not supported.

    Source Error:

    An unhandled exception was generated during the execution of the current web
    request. Information regarding the origin and location of the exception can
    be identified using the exception stack trace below.

    Stack Trace:

    [NotSupportedException: The given path's format is not supported.]
    System.Security.Util.StringExpressionSet.CanonicalizePath(String path,
    Boolean needFullPath) +230
    System.Security.Util.StringExpressionSet.AddExpressions(String[] str,
    Boolean checkForDuplicates, Boolean needFullPath) +461

    System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAcc
    ess access, String[] pathListOrig, Boolean checkForDuplicates, Boolean
    needFullPath, Boolean copyPathList) +401
    System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess
    access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
    +43
    System.IO.Path.GetFullPath(String path) +82
    System.Web.HttpApplication.CheckSuspiciousPhysicalPath(String
    physicalPath) +19
    System.Web.Configuration.HttpConfigurationSystem.ComposeConfig(String
    reqPath, IHttpMapPath configmap) +175
    System.Web.HttpContext.GetCompleteConfigRecord(String reqpath,
    IHttpMapPath configmap) +434
    System.Web.HttpContext.GetCompleteConfig() +49
    System.Web.HttpContext.GetConfig(String name) +195
    System.Web.CustomErrors.GetSettings(HttpContext context, Boolean
    canThrow) +20
    System.Web.HttpResponse.ReportRuntimeError(Exception e, Boolean canThrow)
    +39
    System.Web.HttpRuntime.FinishRequest(HttpWorkerRequest wr, HttpContext
    context, Exception e) +486
     
    Brad, Mar 28, 2005
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.