MVC发布到IIS,出现HTTP 错误 404.0 - Not Found的解决方法

本文介绍了解决.NET 4.5项目在IIS上部署时出现404错误的方法。主要原因是项目配置文件web.config中未正确设置运行环境。通过在web.config中加入特定配置,可以确保所有请求都正确处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

NET项目发布到IIS上报错:HTTP 错误 404.0 - Not Found



原因:由于本机开发环境是Net4.5,所以虽然创建项目时选择的是net framework4.5的,但是webconfig里面指定的运行环境还是net framework4.5的,需要加上

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>IIS 10.0 详细错误 - 404.0 - Not Found</title> <style type="text/css"> <!-- body { margin: 0; font-size: .7em; font-family: Verdana, Arial, Helvetica, sans-serif; } code { margin: 0; color: #006600; font-size: 1.1em; font-weight: bold; } .config_source code { font-size: .8em; color: #000000; } pre { margin: 0; font-size: 1.4em; word-wrap: break-word; } ul, ol { margin: 10px 0 10px 5px; } ul.first, ol.first { margin-top: 5px; } fieldset { padding: 0 15px 10px 15px; word-break: break-all; } .summary-container fieldset { padding-bottom: 5px; margin-top: 4px; } legend.no-expand-all { padding: 2px 15px 4px 10px; margin: 0 0 0 -12px; } legend { color: #333333; ; margin: 4px 0 8px -12px; _margin-top: 0px; font-weight: bold; font-size: 1em; } a:link, a:visited { color: #007EFF; font-weight: bold; } a:hover { text-decoration: none; } h1 { font-size: 2.4em; margin: 0; color: #FFF; } h2 { font-size: 1.7em; margin: 0; color: #CC0000; } h3 { font-size: 1.4em; margin: 10px 0 0 0; color: #CC0000; } h4 { font-size: 1.2em; margin: 10px 0 5px 0; } #header { width: 96%; margin: 0 0 0 0; padding: 6px 2% 6px 2%; font-family: "trebuchet MS", Verdana, sans-serif; color: #FFF; background-color: #5C87B2; } #content { margin: 0 0 0 2%; position: relative; } .summary-container, .content-container { background: #FFF; width: 96%; margin-top: 8px;
04-01
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值