食人鱼 MVC HTTP 404.0 - 未找到
Posted
技术标签:
【中文标题】食人鱼 MVC HTTP 404.0 - 未找到【英文标题】:Piranha MVC HTTP 404.0 - Not Found 【发布时间】:2014-06-16 12:46:58 【问题描述】:我创建了 ASP.NET MVC Empty 项目并使用 NuGet Install-Package PiranhaCMSMvc
安装了 Piranha MVC。经理工作,但我无法打开任何页面。 This thread 没有帮助我
这是我的网络配置
<?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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="piranha" type="Piranha.ConfigFile, Piranha" allowLocation="true" allowDefinition="Everywhere" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Forms">
<forms name="PiranhaCMS" timeout="30" />
</authentication>
<sessionState timeout="30" />
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<piranha>
<settings>
<managerNamespaces value="" />
<disableManager value="false" />
<passiveMode value="false" />
<prefixlessPermalinks value="false" />
</settings>
<providers>
<mediaProvider value="Piranha.IO.LocalMediaProvider, Piranha" />
<mediaCacheProvider value="Piranha.IO.LocalMediaCacheProvider, Piranha" />
<cacheProvider value="Piranha.Cache.WebCacheProvider, Piranha" />
<logProvider value="Piranha.Log.LocalLogProvider, Piranha" />
</providers>
</piranha>
<system.webServer>
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
<urlCompression doStaticCompression="true" />
</system.webServer>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceAuthorization serviceAuthorizationManagerType="Piranha.Web.APIKeyAuthorization, Piranha" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
<connectionStrings>
<add name="piranha" connectionString="data source=myDbServer;initial catalog=EHRHome;user id=sa;password=*****;multipleactiveresultsets=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
【问题讨论】:
你可以尝试直接访问一个页面,即/home/your-permalink来检查默认的起始页路由是否有问题?http://localhost:43142/
的默认路由表示 HTTP 404.0 - Not Found http://localhost:43142/page?permalink=start&piranha-culture=en-EN
,http://localhost:43142/home/start
的路由表示相同的HTTP 404.0 - Not Found http://localhost:43142/page/?permalink=start&piranha-culture=en-EN
【参考方案1】:
如果找不到路由 /page ,则必须缺少模板项目中包含的控制器。确保您的 Controllers 文件夹中存在 PageController 和 PostController。
此外,包含的控制器和 RouteConfig 是 C#,因此如果您使用 VB,则必须转换它们才能正常工作。
在 VS 中创建项目时,请务必勾选将 MVC 包含到项目中的选项,否则您的项目将没有 Global.asax 并且不会配置路由!
希望这会有所帮助!
【讨论】:
以上是关于食人鱼 MVC HTTP 404.0 - 未找到的主要内容,如果未能解决你的问题,请参考以下文章
简单 MVC RoutePrefix - HTTP 错误 404.0 - 未找到
ASP.NET MVC 5 - (HTTP 错误 404.0 - 未找到)具有长的不存在的 URL