2013-03-14 4 views
4

У меня очень простое приложение уровня Hello World, которое я создал в ASP.NET MVC 4/Razor. Он отлично работает в режиме отладки. Нет аутентификации; он просто идет прямо к Home/Index.Почему мое приложение ASP.NET MVC пытается перейти к login.aspx?

Теперь я опубликовал его в IIS. Но когда я просматриваю его через IIS, по какой-то причине он пытается загрузить форму «login.aspx». Я не определял такую ​​форму, а не в web.config, а не где-либо еще в системе. И независимо от того, какой путь я вставляю в URL-адрес, он всегда перенаправляет на несуществующий login.apsx.

ПОЧЕМУ? Как это исправить?

EDIT: в запросы по комментаторам, вот мой Web.config:

<?xml version="1.0" encoding="utf-8"?> 
<!-- 
    For more information on how to configure your ASP.NET application, please visit 
    http://go.microsoft.com/fwlink/?LinkId=169433 
    --> 
<configuration> 
    <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    <sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core"> 
     <section name="messaging" type="DotNetOpenAuth.Configuration.MessagingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true" /> 
     <section name="reporting" type="DotNetOpenAuth.Configuration.ReportingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true" /> 
     <section name="openid" type="DotNetOpenAuth.Configuration.OpenIdElement, DotNetOpenAuth.OpenId" requirePermission="false" allowLocation="true" /> 
     <section name="oauth" type="DotNetOpenAuth.Configuration.OAuthElement, DotNetOpenAuth.OAuth" requirePermission="false" allowLocation="true" /> 
    </sectionGroup> 
    </configSections> 
    <connectionStrings> 
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-AdminBackdoor-20130314103822;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-AdminBackdoor-20130314103822.mdf" providerName="System.Data.SqlClient" /> 
    <add name="MyProjectEntities" connectionString="metadata=res://*/MyProjectEntities.csdl|res://*/MyProjectEntities.ssdl|res://*/MyProjectEntities.msl;provider=System.Data.SqlClient;provider connection string='data source=localhost;initial catalog=MyProject;Integrated Security=True; ;MultipleActiveResultSets=True;App=EntityFramework'" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <appSettings> 
    <add key="webpages:Version" value="2.0.0.0" /> 
    <add key="webpages:Enabled" value="false" /> 
    <add key="PreserveLoginUrl" value="true" /> 
    <add key="ClientValidationEnabled" value="true" /> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" /> 
    <authentication mode="None"> 
     <!--<forms loginUrl="~/Account/Login" timeout="2880" />--> 
    </authentication> 
    <pages> 
     <namespaces> 
     <add namespace="System.Web.Helpers" /> 
     <add namespace="System.Web.Mvc" /> 
     <add namespace="System.Web.Mvc.Ajax" /> 
     <add namespace="System.Web.Mvc.Html" /> 
     <add namespace="System.Web.Optimization" /> 
     <add namespace="System.Web.Routing" /> 
     <add namespace="System.Web.WebPages" /> 
     </namespaces> 
    </pages> 
    </system.web> 
    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <handlers> 
     <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /> 
     <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /> 
     <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> 
     <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> 
     <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 
     <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> 
    </handlers> 
    </system.webServer> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    <legacyHMACWarning enabled="0" /> 
    </runtime> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 
    </entityFramework> 
    <system.net> 
    <defaultProxy enabled="true" /> 
    <settings> 
     <!-- This setting causes .NET to check certificate revocation lists (CRL) 
       before trusting HTTPS certificates. But this setting tends to not 
       be allowed in shared hosting environments. --> 
     <!--<servicePointManager checkCertificateRevocationList="true"/>--> 
    </settings> 
    </system.net> 
    <dotNetOpenAuth> 
    <messaging> 
     <untrustedWebRequest> 
     <whitelistHosts> 
      <!-- Uncomment to enable communication with localhost (should generally not activate in production!) --> 
      <!--<add name="localhost" />--> 
     </whitelistHosts> 
     </untrustedWebRequest> 
    </messaging> 
    <!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. --> 
    <reporting enabled="true" /> 
    <openid> 
     <relyingParty> 
     <security requireSsl="false"> 
      <!-- Uncomment the trustedProviders tag if your relying party should only accept positive assertions from a closed set of OpenID Providers. --> 
      <!--<trustedProviders rejectAssertionsFromUntrustedProviders="true"> 
         <add endpoint="https://www.google.com/accounts/o8/ud" /> 
        </trustedProviders>--> 
     </security> 
     <behaviors> 
      <!-- The following OPTIONAL behavior allows RPs to use SREG only, but be compatible 
         with OPs that use Attribute Exchange (in various formats). --> 
      <add type="DotNetOpenAuth.OpenId.RelyingParty.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth.OpenId.RelyingParty" /> 
     </behaviors> 
     </relyingParty> 
    </openid> 
    </dotNetOpenAuth> 
    <uri> 
    <!-- The uri section is necessary to turn on .NET 3.5 support for IDN (international domain names), 
      which is necessary for OpenID urls with unicode characters in the domain/host name. 
      It is also required to put the Uri class into RFC 3986 escaping mode, which OpenID and OAuth require. --> 
    <idn enabled="All" /> 
    <iriParsing enabled="true" /> 
    </uri> 
</configuration> 
+1

Может ли быть родительский веб-сайт в IIS, из которого ваше приложение может наследовать настройки web.config? –

+0

Включен ли разрешенный аноним в IIS> Правила авторизации? – Oliver

+0

@DarinDimitrov - зачем? В корневой папке веб-сайта есть web.config. (В любом случае, нет, нет родительского web.config.) –

ответ

5

О, ужас и стыд. «Анонимные пользователи» были разрешены в IIS в разделе «Правила авторизации» ... но «Анонимная аутентификация» была отключена в разделе «Аутентификация».

я получу за мое смущение и не удалять этот вопрос ради будущих программистов, которые могут извлечь выгоду из этого ...

+0

Спасибо за это! У меня была такая же проблема, хотя я никогда не помню, как это меняю в IIS. – TheWebGuy

6

Если кто-то приходит на это, есть еще потенциал раствора, как описано в this other SO question , Удалите библиотеки WebMatrix из каталога bin.

Возможно, эта проблема возникает, если вы используете «Добавить расширяемые зависимости» из VS 2010. Это включает материал WebMatrix, который, в свою очередь, взрывает вашу аутентификацию при определенных обстоятельствах. В этом случае удалите WebMatrix из каталога _bin_deployableAssemblies, который, в свою очередь, не будет использоваться во время сборки или развертывания.

+0

Вы, вы заслуживаете что-то особенное для этого. – Slidell4life

+0

Удаление библиотек WebMatrix сделало это для меня. Благодаря :) –