由于公司需要,原来在windows server 2003上运行的网站需要迁移到新的服务器上(win server 2008)
IIS由原来的6.0升级为7.0
网站原来做的伪静态就遇到了问题
最初迁移后默认的应用程序池是集成模式的,访问直接报500错误
然后换成经典模式并且完成了伪静态的相关配置,访问不会报错了,但是所有样式图片全部丢失
路径上完全没有问题,通过路径直接访问样式文件和图片也全是404错误
求解决方案

解决方案 »

  1.   

    404错误不就是路径问题吗
    原来IIS6下对css,图片进行重写了吗?对这些扩展名进行设置了吗
      

  2.   

    重定向都是通过rewrite类的代码实现的
      

  3.   

    你应该是这些扩展名没有进行处理,原来是把css,jpg等这些静态扩展名映射到asp.net处理程序的,现在也应该做同样的设置,这些文件是静态文件,默认直接由IIS返回,不经过asp.net处理程序的
      

  4.   

    图片文件在IIS里面映射下就 OK了  然后在直接访问图片路径看是什么
     对比下网站访问路径 就知道问题所在了 
      

  5.   

    配置过了,添加了脚本映射似乎不起作用,请问是用iisapi来处理吗
      

  6.   

    在 IIS 7 中配置处理程序映射
    http://technet.microsoft.com/zh-cn/library/cc771240(v=ws.10).aspxIIS7.0设置 url重写成html(伪静态)
    http://goslam.cn/ArtView.aspx?id=272http://www.2cto.com/os/201105/90045.html
      

  7.   

    iis7本身带的有重写功能
    http://www.ej38.com/showinfo/html-176771.html
      

  8.   

    试过很多办法了,通过IIS配置映射,直接修改配置文件,都不能解决,求高人指点~~~
      

  9.   

    根据你的描述,应该是将jpg,css等文件都映射给framework处理了。3#说的很清楚了。
    具体什么问题最好把你的配置步骤说出来才能知道。
      

  10.   

    程序原来的开发已经不在了,原来的配置环境无从知晓,现在的问题是网站迁移到IIS7环境后无法在集成模式下运行,直接报500错误,只能在经典模式下运行,不知道会不会影响到原来的映射关系
      

  11.   

    发布到IIS7以后正常的伪静态配置流程都走过了,应用程序池默认是集成模式的,直接500错误,换成经典模式以后所有的静态文件(css,图片)就都不能访问了,页面样式全部丢失
      

  12.   

    iis7中网站都是配成经典,你先把url重写去掉,一切都配好之后不要动,然后再在配置文件里加上配的url重写,isapi也在文件里写,如果还有样式和图片不出来的话,把页面上的样式引用都用绝对路径的写法试试,如link source='/css/aa.css'
      

  13.   

    原来的程序员没有用通用的urlrewrite库,是自己写代码实现了httpmodule,代码如下
    public void Init(HttpApplication context)
        {
            context.AuthenticateRequest += new EventHandler(context_AuthenticateRequest);
        }
        void context_AuthenticateRequest(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;
            HttpRequest request = app.Context.Request;        //是否为文件
            if (app.Context.Request.Url.IsFile)
            {
                return;
            }
            string exe = ".htm";
            string[,] rewriteUrlReplace = new string[,] { 
           //
          {"sicklist","sl",exe,"cid,page","__","_"},
          {"sickfinally","sf",exe,"id","__","_"},
          {"index","index",exe,"","",""},
           //
          {"media","media",exe,"","",""},
          {"medialist","ml",exe,"id,page","__","_"},
          {"mediafinally","mf",exe,"id,mid","__","_"},
           //
          {"interview","interview",exe,"","",""},
          {"interviewlist","it",exe,"id,page,Inid","__","_"},
          {"interviewvedio","iv",exe,"id,cid","__","_"},
          {"InterviewFinally","itf",exe,"id,fid","__","_"},
           //
          {"about","about",exe,"","",""},
          {"aboutUs","aboutUs",exe,"id","__","_"},
          {"aboutMachine","machine",exe,"id","__","_"},
          {"tream","treamv",exe,"id","__","_"},
          {"DynamicList","dl",exe,"id","__","_"},
          {"DynamicFinally","df",exe,"id,fid","__","_"},
           //
          {"tream","tream",exe,"","__","_"},
          {"tream","treamx",exe,"id","__","_"},
          {"caseInfo","caseInfo",exe,"cid,infoID","__","_"},//案例祥页
          {"ccDocList","ccDocList",exe,"id,cenid","__","_"},
          {"centerDocList","cdlist",exe,"id,cenid","__","_"},
          {"docCaseList","docCaseList",exe,"cid","__","_"},//案例列表
          {"docInterList","docInterList",exe,"id,cid","__","_"},
          {"doctorInfo","doctorInfo",exe,"rid,cid","__","_"},
          {"interInfo","interInfo",exe,"infoID,cid","__","_"},
          {"doctorList","doctorList",exe,"id","__","_"},
           //
            {"service","service",exe,"","__","_"},
            {"serviceCenter","sc",exe,"id","__","_"},
            {"centerInfo","centerinfo",exe,"id,infoID","__","_"},
            {"centerList","cl",exe,"id,mid,page","__","_"},
            {"centerPrice","cp",exe,"id,mid","__","_"},
            //
            {"Answer","Answerdt",exe,"qid,id","__","_"},
            {"info","aboutinfo",exe,"id","__","_"},
            {"leaveMsg","leaveMsg",exe,"id","__","_"},
            {"SiteMap","SiteMap",exe,"id","__","_"},
            //
            {"members","members",exe,"","__","_"},
            {"biaozhun","biaozhun",exe,"","__","_"},
            {"baijin","baijin",exe,"","__","_"},
            {"guibin","guibin",exe,"","__","_"},
            {"Card","Card",exe,"id","__","_"},
                {"memberInfo","memberInfo",exe,"id","__","_"},
            //
            {"huoban","huoban",exe,"id","__","_"},
            {"Alliance","Alliance",exe,"id","__","_"},
            {"BankVIP","BankVIP",exe,"id","__","_"},
            {"HealthContract","hc",exe,"id","__","_"},
            {"Insurance","Insurance",exe,"id,bid","__","_"},
            {"MeitiHB","MeitiHB",exe,"id","__","_"},
            {"sokq","sokq",exe,"id","__","_"},
                //
            {"tastInfo","tastInfo",exe,"id","__","_"},
            {"cardInfo","cardInfo",exe,"id","__","_"},
             //
            {"result","result",exe,"key,page","__","_"},
            //
            {"yazhi","yazhi",exe,"","__","_"},
            {"yazhiList","yazhiList",exe,"id","__","_"},
            {"yazhiInfo","yazhiInfo",exe,"id,infoID","__","_"},
                //
                //{"index","index",exe,"","__","_"},
          };        string str = request.Url.ToString();
            if (str.IndexOf("sick") > 0)
            {
                string id = str.Substring(str.LastIndexOf("=") + 1);
                if (str.LastIndexOf("?id") > 0)
                {
                    str = "http://www.kowa-dental.net/id_" + id + "__sf.htm";
                    app.Context.Response.Redirect(str);
                    return;
                }
                else if (str.LastIndexOf("?cid") > 0)
                {
                    str = "http://www.kowa-dental.net/cid_" + id + "__sl.htm";
                    app.Context.Response.Redirect(str);
                    return;
                }
            }
            //if (str.Contains("/index.aspx") || str.Contains("/index.htm"))
            //{
            //    app.Context.Response.Redirect("http://ss.sokq.com/");
            //    return;
            //}
            string authURL = request.Url.AbsolutePath.ToLower();
            if (authURL.Contains(".asp") && !authURL.Contains(".aspx"))
            {
                app.Context.RewritePath("/welcome.aspx");
                return;
            }
            string rewriteURL = TargetStaticUrl(authURL, rewriteUrlReplace);
            //if (!string.IsNullOrEmpty(rewriteURL)) app.Context.RewritePath(rewriteURL);        if (!string.IsNullOrEmpty(rewriteURL)) app.Context.RewritePath(rewriteURL);
            else if (!authURL.Contains(".aspx")) app.Context.RewritePath("/404.aspx");
       
        }
        #endregion
        /// <summary>
        /// 分页伪静态处理方法
        /// </summary>
        public static string TargetStaticUrl(string authURL, string[,] rewriteUrlReplace)
        {
            for (int i = 0; i < rewriteUrlReplace.GetLength(0); i++)
            {
                //存在当前扩展名的URL
                if (authURL.Contains(rewriteUrlReplace[i, 1].ToLower() + rewriteUrlReplace[i, 2]))
                {
                    //当前访问的静态地址
                    string pagename = authURL.Substring(authURL.LastIndexOf("/") + 1);
                    //转发地址
                    string rewriteURL = rewriteUrlReplace[i, 0].ToLower() + ".aspx";
                    //页面参数
                    string query = pagename.Replace(rewriteUrlReplace[i, 1].ToLower() + rewriteUrlReplace[i, 2], "");
                    #region 伪静态转动态路径
                    if (!string.IsNullOrEmpty(query))
                    {
                        rewriteURL += "?";
                        Regex regex = new Regex(rewriteUrlReplace[i, 4]);
                        string[] items = regex.Split(query);
                        string[] paramterKeys = rewriteUrlReplace[i, 3].Split(',');
                        foreach (string item in items)
                        {
                            if (!item.Contains(rewriteUrlReplace[i, 5]))
                            {
                                continue;
                            }
                            string key = item.Split(rewriteUrlReplace[i, 5].ToCharArray()[0])[0];
                            string value = item.Split(rewriteUrlReplace[i, 5].ToCharArray()[0])[1];
                            string queryItem = "";
                            for (int j = 0; j < paramterKeys.Length; j++)
                            {
                                if (key == paramterKeys[j].ToLower())
                                {
                                    queryItem = key + "=" + value;
                                }
                            }
                            //判断数据项
                            if (string.IsNullOrEmpty(queryItem))
                            {
                                continue;
                            }
                            rewriteURL += "&" + queryItem;
                        }//foreach end
                    }
                    #endregion 伪静态转动态路径 结束
                    //处理程序跳转
                    return rewriteURL;
                }// end
            }
            return "";
        }