2013-10-27 36 views
19

我在使用Twitter引導啓動MVC4應用程序時遇到了問題。如何解決MVC4 Twitter Bootstrap項目在VS2012中的簡單Nuget安裝失敗?

在VS 2012年,我創建了一個新的空MVC4應用程序,安裝以下軟件包:

  • 安裝,包裝twitter.bootstrap.mvc4
  • 安裝,包裝twitter.bootstrap.mvc4.sample

看起來像一些導航路線選項相關的問題,因爲我正在經歷這些少數幾個地區Link 1Link 2

在閱讀有關可能的說明編譯的問題,我重新啓動了解決方案,但我收到的錯誤是不是自述的那些,並重點圍繞NavigationRouteOptionsNavigationRouteFiltersRouteValueDictionaryFilterTokenHasFilterToken

'System.Web.Routing.RouteValueDictionary' does not contain a definition for 'HasFilterToken' and no extension method 'HasFilterToken' accepting a 
first argument of type 'System.Web.Routing.RouteValueDictionary' could be found (are you missing a using directive or an assembly reference?) 
...\AdministrationRouteFilter.cs 18 

'System.Web.Routing.RouteValueDictionary' does not contain a definition for 'FilterToken' and no extension method 'FilterToken' accepting a 
first argument of type 'System.Web.Routing.RouteValueDictionary' could be found (are you missing a using directive or an assembly reference?) 
..\AdministrationRouteFilter.cs 20 

The name 'NavigationRouteFilters' does not exist in the current context 

'NavigationRouteOptions' could not be found (are you missing a using directive or an assembly reference?) 

我已確認我確實已安裝了navigationroutes.mvc4 Nuget包。

這隻適用於VS 2013?

的的NuGet包的日期爲10月26日,2013年

援助表示讚賞。

+0

這是11月19日,我有與VS2012中的NuGet安裝包同樣的問題。當我應用Muthu提供的修復程序時,由於Application_Start()中的重複調用到RegisterRoutes(),導致運行時錯誤。我很驚訝這個問題還沒有得到解決...... – Sephrial

+0

因此,將Nuget軟件包應用於項目始終存在危險 - 您並不總是知道它們作爲依賴項添加的內容,只是添加它們並不能你有一個關於它們如何連接的好主意.Bootstrap只是一個UI模板。我應用了自己的模板,並將它連接到自己......沒有捷徑。 – ElHaix

+0

順序安裝/卸載將工作如下 PM>安裝,包裝twitter.bootstrap.mvc4 - 版本1.0.90 PM>安裝,包裝twitter.bootstrap.mvc4.htmlhelpers - 版本1.0.90 PM>安裝-Package twitter.bootstrap.mvc4.sample -Version 1.0.90 –

回答

35

似乎已經有關於誤差github

嘗試卸載1.1.100的討論,並按照以下順序安裝1.0.90版本。

  • PM>安裝,包裝twitter.bootstrap.mvc4.sample -Version 1.0.90
  • PM>卸載,包裝twitter.bootstrap.mvc4.htmlhelpers -Force
  • PM>安裝,包twitter.bootstrap.mvc4.htmlhelpers -version 1.0.90
  • PM>卸載,包裝twitter.bootstrap.mvc4 -Force
  • PM>安裝,包裝twitter.bootstrap.mvc4 - 版本1.0.90
+1

謝謝。這讓我進一步了,但是,在Global.asax.cs中存在'* .RegisterBundles'和'* .RegisterRoutes'的重複條目,這會導致重複的與路由相關的異常。刪除那些渲染UI但沒有找到CSS和'/ bundles/modernizr' ... – ElHaix

+1

哪個瀏覽器? – Muthu

+0

共享佈局文件包含無效的CSS路由;取代了這些,但也注意到引用'〜/ Content/css-responsive' - 它不存在。某處是否存在穩定的安裝過程? – ElHaix

5

早上好夥計們,我遇到了完全一樣的問題,至少對我來說,這個工作>

而不是安裝twetter.bootstrap,只需安裝引導軟件包,因爲它看起來像與發佈vs2013,他們只是把包裹交給MS維護。

所以,卸載你當前的引導版本,(推特一),只需安裝一般引導程序。 (或一定要安裝版本3.0.2)

install-package bootstrap 

請注意此修復,適用於VS2k12。

+0

是的,我和OP以及其他所有人都有同樣的問題,所以我卸載了所有的東西,並按照您的建議運行「install-package bootstrap」,並且所有的東西都可以用來說話。謝謝!! – hardba11

+0

對我來說也是如此。謝謝@Pablo Contreras – Bazinga

0

Muthu的解決方案如果你創建一個VS2012項目(基本---不是互聯網!),然後在bootstrapLayout.basic.cshtml(你可以在共​​享文件夾中找到)添加CSS文件並添加Javascript bootstrapLayout.basic.cshtml底部的文件。這是我的bootstraplayout.basic.cshtml。注意...腳本文件的順序很重要(祝你好運!)...並感謝Mithu!

@using System.Web.Optimization 
@using BootstrapSupport 
@using NavigationRoutes 
<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <meta charset="utf-8"> 
     <title>@ViewBag.Title</title> 
     <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
     @*<link href="@Styles.Url("~/content/css")" rel="stylesheet"/>*@ 
@* @Styles.Render("~/Content/bootstrap.min.css") 
    @Scripts.Render("~/bundles/modernizr")*@ 
     <link href="~/Content/body.css" rel="stylesheet" /> 
     <link href="~/Content/bootstrap.min.css" rel="stylesheet" /> 
     <link href="~/Content/bootstrap-responsive.min.css" rel="stylesheet" /> 
     @RenderSection("head", required: false) 
     @Html.Partial("_html5shiv") 
     @* favicons and touch icons go here *@ 
    </head> 
    <body> 
     <div class="navbar navbar-inverse navbar-fixed-top"> 
      <div class="navbar-inner"> 
       <div class="container"> 
        <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> 
         <span class="icon-bar"></span> 
         <span class="icon-bar"></span> 
         <span class="icon-bar"></span> 
        </a> 
        <a class="brand" href="#" title="change in _bootstrapLayout.basic.cshtml">Application Name</a> 
        <div class="nav-collapse collapse"> 
         <ul class="nav"> 
          @Html.Navigation() 
         </ul> 
        </div> 
       </div> 
      </div> 
     </div>   
     <div class="container"> 
      @Html.Partial("_alerts") 
      @Html.Partial("_validationSummary") 
      @RenderBody() 
      <hr> 
      <footer> 
       <p>&copy; Company @System.DateTime.Now.ToString("yyyy")</p> 
      </footer> 
     </div> 
     @*@Scripts.Render("~/js")*@ 
     <script src="~/Scripts/jquery-1.9.1.min.js"></script> 
     <script src="~/Scripts/jquery-ui-1.8.24.min.js"></script> 
     <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script> 
     <script src="~/Scripts/jquery.validate.min.js"></script> 
     <script src="~/Scripts/jquery.validate.unobtrusive-custom-for-bootstrap.js"></script> 
     <script src="~/Scripts/knockout-2.2.0.js"></script> 
     <script src="~/Scripts/bootstrap.min.js"></script> 

     @RenderSection("Scripts", required: false) 
    </body> 
</html> 
相關問題