我做了个网站,本地运行一点问题都没有,可是把复制的项目文件部署到服务器后,
做后台的操作时,会报以下错误:
Server Error in '/' Application.
--------------------------------------------------------------------------------Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File --><configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File --><configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
小弟经验不多,看哪位高手能帮忙解释一下!
谢谢!
做后台的操作时,会报以下错误:
Server Error in '/' Application.
--------------------------------------------------------------------------------Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File --><configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File --><configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
小弟经验不多,看哪位高手能帮忙解释一下!
谢谢!
服务器平时不方便使用,有没有办法能在客户端显示详细错误信息?
服务器平时不方便使用,有没有办法能在客户端显示详细错误信息?
--------------------------------------------
调试信息说的很清楚了啊,
<!-- Web.Config Configuration File --><configuration>
<system.web>
<customErrors mode="Off"/> <---在web.config中改这里
</system.web>
</configuration>
或者在global.asax中Application_Error插入自定义处理代码
这样就能看出详细错误了.
在用vs2003编写原代码的时候,网站是在IIS的建立的虚拟目录,而在部署时,网站是部署在服务器的默认网站,以至于图片的存取出现错误.
教训深刻!
我还想问一下,如果我不想改变原来的代码,
怎么能在访问服务器的IP的时候直接访问默认网站的某个虚拟目录?
现在的相对路径是这样取得的,
Server.MapPath("../虚拟目录名称/user/"+ Session["userID"].ToString() +"/images/"+mc[i].Value)))
可是网站在服务器上被设置为默认网站,如果是需要改代码的话,改动的地方就太多了,
怎么通过更改服务器的设置解决这个问题呢?
根据经验最可能的错误就是,虚拟目录问题.
导致你那种错误的原因是你没有创建应用程序池方法:进入IIS 查看 网站属性 应用程序设置 应用程序名 里面有名字的话 就直接点创建
就可以了!
------------------------------------------------
只要你不把该目录放到默认站点下
而是在iis网站的根新建一个站点,指向你的web工程的目录
然后在配置站点属性-〉文档-〉启用默认-〉添加INDEX.ASPX即可实现
谢谢你,你可能没明白我的意思,
因为在编写网站的时候,WEB项目是在IIS->站点->虚拟目录,
其中很多代码里都是
Server.MapPath("../虚拟目录名称/user/"+ Session["userID"].ToString() +"/images/"+mc[i].Value)))
取得相对路径的,
现在我把网站部署到服务器上的默认目录,在取相对路径就出错了,
如果我要是更改代码的话,需要改的东西就会很多,
所以我想在站点虚拟目录下映射站点,
可是不知道怎么处理才好
Server.MapPath取得的是绝对路径,如:d:\test\mypic.jpg等,和默认站点的磁盘路径指向也无关系。
你的
"目录名称/user/"+ Session["userID"].ToString() +"/images/"+mc[i].Value
是否在部署后路径有一部分缺失,为何部署后与本机不同,可否详细说明下
上面的虚拟目录名称就是复制项目后文件夹名称,也是在服务器上默认网站影射的文件夹名称
Server.MapPath("../虚拟目录名称/user/"+ Session["userID"].ToString() +"/images/"+mc[i].Value)))
上面的虚拟目录名称是编写代码时放web页面文件夹名称
http://localhost/RoadCenter/index.aspx
在这个目录下路径就不会有问题
http://localhost/index.aspx
默认网站的路径就出错了所以我现在想把网站部署在服务器的虚拟目录下,
可是我不知道怎么设置才能使访问服务器的IP 的时候直接访问这个虚拟目录.
大伙帮我想想办法吧
http://localhost/index.aspx
-------------------------------------
是不是这个意思?