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.

  • 相关阅读:
    无法往u盘里边复制超过4G的单个文件解决方法
    vue 自定义属性判断点击每个item 显示隐藏
    前端小组分享会之异步回调函数中的上下文
    git 的一些命令
    ES学习之promise
    mac找到占用端口号的进程ID
    meta link
    webpack学习笔记--安装
    css样式之 direction
    日常积累之JSON.stringify和JSON.parse substr
  • 原文地址:https://www.cnblogs.com/rickie/p/1980266.html
Copyright © 2011-2022 走看看