zoukankan      html  css  js  c++  java
  • URL Rewriter and IIS configuration

    Suppose you want to use http://XXX/aa-bb  as your displayed url, but you want to remove the extension from your URL and the actual URL is http://XXX/aa-bb.aspx. You can write some codes by yourself to implement URL Rewriting feature.

    But there is a problem. The code only works on dev box. when hosted in production I keep getting 404s error when requesting http://XXX/aa-bb, only http://XXX/aa-bb.aspx can work.

    So you got to do some configuration in IIS to solve this problem. Dont't forget that mapping "*all*" requests to asp.net. Here is how-to:

    In IIS6, go to home directory tab, click "configuration" and "add a wildcard map to the following file ".

    browse to "c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll" and enter .*

    ensure that 'check that file exists' is unchecked.

     

    But everything has two sides. It will slow down the performance more or less. secondly, by unchecking "check that file exists" will bring about another problem you will experience. You can not utilize the Error 404 ability provided by IIS to catch error 404 'file not found' to redirect your request to a page you specify.

    There is another way to implement URL rewriter. You can use error 404 ability to get the request like "http://XXX/aa-bb" in the aspx page you specify in IIS and then transfer this page to the phisical page you want. But the head status in response for this aspx page will be changed to 404 and the header might be rewrited, which will cause some problems when your websites are required to do SEO since some websites spiders and crawers will ignore error 404 and stop processing this page. Secondly, the css or js defined in the header might reference to wrong link path. I ran into this problem. But actually I don't know exactly what happened inside.

    There is one tiny thing we need to notice. When you implement URL rewriter, Suppose you have a displayed URL, Let's say  http://XXX/newview/Military", and you want to rewrite it to http://XXX/newview.aspx?Title=Military.

    As you can see here, the directory path level is decreased from 2 to 1. So when you use css link like "../css/global.css" you cannot find the css file. So you need to use Resolve("~/Css/global.css") method provided by asp.net.

  • 相关阅读:
    亲和数
    改革春风吹满地
    处理选中图片
    项目架构(结构)搭建:主流结构(UITabBarController + 导航控制器)
    iOS应用启动main函数
    LaunchScreen&LaunchImage
    颜色常识
    折半查找法(二分法)
    冒泡排序
    多用户登录
  • 原文地址:https://www.cnblogs.com/rickie/p/1980266.html
Copyright © 2011-2022 走看看