Wal*_*orn 16 .net iis asp.net-mvc firefox static-files
(我是.Net和微软世界的新手,来自Java和Tomcat背景,所以请记住这一点.)
我正在使用Visual Studio 2013,C#,.Net 4.5,MVC 5和EF 6开发我的第一个.Net应用程序.这是一个相当简单的基于Web的应用程序,使用Windows身份验证和Active Directory组授权公平地执行SQL Server数据库中表的基本CRUD操作.
我还没有部署应用程序.我还在开发它并在我的PC上运行(运行Windows 7).当我按下Ctrl-F5在Internet Explorer或Google Chrome中测试应用程序时,一切正常.
但是,如果我告诉Visual Studio在Firefox中访问它,它会显示没有任何CSS或JavaScript 的页面.我可以单击应用程序中的链接并导航到各个页面,这些页面都可以正常工作.它们只显示没有任何CSS或工作JavaScript.当我手动尝试查看其中一个CSS或JavaScript文件时,我收到内部服务器错误(HTTP错误500).检查日志文件会显示页面尝试加载的每个CSS和JavaScript文件的状态代码500.
我很神秘,因为它可以从Internet Explorer和Chrome中正常工作.如何使用不同的Web浏览器导致此内部服务器错误?
我发布了一些代码,但此时我不知道有什么用处.(我可以显示IIS Express正在记录哪些附加信息,如果有的话,但我不知道在哪里可以找到它,除了显示状态代码500的行.)
在开发的早期阶段,我意识到当我希望它被命名为"Version"(大写)时,我已经命名了一些数据库字段"version".我在该字符串的整个解决方案中进行了全局查找/替换,而不是对该字段进行重命名.可能有一些重要的事情被这个过程所困扰,但我已经对"版本"(以及"版本")进行了全局查找,并且没有找到任何值得注意的内容.
如果我绝对必须,我可能只是从头开始重新创建项目,并希望我不会将同样的问题(或新问题)复制/粘贴到新项目中,但我希望有人能来有一些比较容易尝试的东西.
这是Views/Shared/_Layout.cshtml的开头:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - Experiment 626</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
Run Code Online (Sandbox Code Playgroud)
这是App_Start\BundleConfig.cs:
using System.Web;
using System.Web.Optimization;
namespace Experiment626
{
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate.min.js",
"~/Scripts/jquery.validate.unobtrusive.min.js"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap-theme.css",
"~/Content/site.css"));
}
}
}
Run Code Online (Sandbox Code Playgroud)
查看Firebug,对于每个CSS或JavaScript文件,请求和响应标头如下所示:
GET /Content/site.css HTTP/1.1
Host: localhost:6365
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0
Accept: text/css,*/*;q=0.1
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://localhost:6365/
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Run Code Online (Sandbox Code Playgroud)
HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/8.0
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcV2FsbHkuSGFydHNob3JuXFZpc3VhbCBTdHVkaW8gMjAxM1xQcm9qZWN0c1xFeHBlcmltZW50NjI2XEV4cGVyaW1lbnQ2MjZcQ29udGVudFxzaXRlLmNzcw==?=
Persistent-Auth: true
X-Powered-By: ASP.NET
Date: Tue, 25 Feb 2014 21:13:50 GMT
Content-Length: 5870
Run Code Online (Sandbox Code Playgroud)
为了进行比较,以下是使用Chrome时的请求标头:
Accept:text/css,*/*;q=0.1
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Host:localhost:6365
Pragma:no-cache
Referer:http://localhost:6365/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36
Run Code Online (Sandbox Code Playgroud)
在IIS显示的默认错误页面中,有一个详细错误信息部分,其中包含:
Module IIS Web Core
Notification AuthenticateRequest
Handler StaticFile
Error Code 0x80070542
Requested URL http://localhost:6365/Content/site.css
Physical Path C:\Users\Wally.Hartshorn\Visual Studio 2013\Projects\Experiment626\Experiment626\Content\site.css
Logon Method NTLM
Logon User SOMEDOMAIN\Wally.Hartshorn
Request Tracing Directory \\something.domain.com\SPIUsers1\Wally.Hartshorn\IISExpress\TraceLogFiles\EXPERIMENT626
Run Code Online (Sandbox Code Playgroud)
我仍然无法弄清楚如何查看触发状态代码500所引发的实际异常.
研究错误代码,我发现它显然意味着"未提供所需的模拟级别,或者提供的模拟级别无效".我猜测Firefox处理身份验证的方式与Internet Explorer和Google Chrome的方式有所不同,但我还不知道如何解决这个问题.
作为实验,我在Visual Studio 2013中创建了一个全新的ASP.NET MVC项目,选择了Windows身份验证.然后,在不对此全新解决方案进行任何更改的情况下,我按Ctrl-F5构建它并在Firefox中打开默认主页.我在未触及的项目中得到完全相同的错误 - HTTP Server Error 500.0,错误代码为0x80070542
,表示"未提供所需的模拟级别,或者提供的模拟级别无效".
显然它与我的代码无关,而是我的Visual Studio 2013,IIS Express和/或Windows 7的配置方式的基本问题.
我很难过.
Wal*_*orn 33
G_P向我指出了我的问题的解决方案.根本原因显然是Firefox默认不使用Windows集成身份验证,除非该站点是可信任的.
要在Firefox中启用Windows集成身份验证:
about:config
在地址栏中输入.network.automatic
.network.automatic-ntlm-auth.trusted-uris
.localhost
或mycompany.com
.之后它工作正常.
不幸的是,这意味着要指导公司中每个想要使用Firefox访问应用程序的人,他们必须进行此更改(否则IT部门必须找到一种方法).在这个特定的应用程序中,这不是什么大问题,因为用户数量会非常少.对于以后的应用程序,我可能需要弄清楚其他的东西.(也许我应该研究Windows Identity Foundation?但听起来有些可怕.)
在任何情况下,我都会称之为"现在足够好"并继续我的生活.非常感谢帮助我的每个人!
PS两页有可能有用的信息:
归档时间: |
|
查看次数: |
8562 次 |
最近记录: |