2010-06-09 35 views

Trả lời

29

Via Reflection:

typeof (Controller).Assembly.GetName().Version 
+0

rất đẹp! Tôi đã kiểm tra MvcHandler.GetMvcVersionString() trong mã nguồn mvc (nhưng phương thức riêng, hối tiếc ..). – takepara

133
  1. Tới thư mục tài liệu tham khảo của bạn
  2. nhìn cho system.web.mvc
  3. Right Click vào nó
  4. Bấm Thuộc tính
  5. Nhìn vào bất động sản Version.

này rất có thể là phiên bản của bạn nhưng GAC có thể đóng một vai trò trong việc rối tung bạn xung quanh

1

Trên cơ hội ra bạn không có quyền truy cập vào mã và/hoặc muốn xác định phiên bản của ASP. NET đã được triển khai trên một máy, bạn có thể làm như sau (từ TechNet):

làm thế nào để xác định phiên bản của ASP.NET MVC được cài đặt trên hệ thống của tôi?

Đối với MVC 4.0, MVC 5.0 hoặc MVC 5.1, bạn nên triển khai tệp nhị phân bị ảnh hưởng (System.Web.MVC.dll) bằng ứng dụng của mình. Kiểm tra thư mục bin của ứng dụng cho phiên bản nhị phân. Đối với MVC 2.0, MVC 3.0 hoặc MVC 4.0, tham khảo bảng điều khiển Thêm hoặc Loại bỏ Chương trình mục cho phiên bản MVC được cài đặt.

-2

Sử dụng gói NuGet MvcDiagnostics mà bạn có thể cài đặt. Tạo một MVC "hello world" hoặc một số chương trình cơ bản khác, sau đó cài đặt gói này. Quá trình cài đặt sẽ nhắc cho dự án thêm tệp vào. Xác nhận và bạn sẽ thấy MvcDiagnostics.aspx được thêm vào dự án của bạn. Nhấp chuột phải vào tệp này trong trình xem giải pháp, sau đó chọn "Xem trong trình duyệt". Sau đó, bạn sẽ thấy một trang đẹp với tất cả thông tin lắp ráp của bạn. Mine trông giống như sau:

Microsoft ASP.NET MVC Diagnostics Information 

This page is designed to help diagnose common errors related to mismatched or conflicting ASP.NET MVC binaries. If a known issue is identified, it will be displayed below in red text. 

For questions or problems with ASP.NET MVC or this utility, please visit the ASP.NET MVC forums at http://forums.asp.net/1146.aspx. 

Environment Information 

Operating system: Microsoft Windows NT 6.2.9200.0 
.NET Framework version: 4.0.30319.34209 (32-bit) 
Web server: Microsoft-IIS/8.0 
Integrated pipeline: True 
Worker process: iisexpress.exe 
AppDomain: Homogenous = True, FullTrust = True 

ASP.NET MVC Assembly Information (System.Web.Mvc.dll) 

Assembly version: ASP.NET MVC 4 RTM (4.0.20710.0) 
Full name: System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
Code base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Web.Mvc/v4.0_4.0.0.0__31bf3856ad364e35/System.Web.Mvc.dll 
Deployment: GAC-deployed 

ASP.NET MVC Futures Assembly Information (Microsoft.Web.Mvc.dll) 

An ASP.NET MVC Futures assembly has not been loaded into this application. A download for this version of ASP.NET MVC Futures is not available. Pre-release versions of the MVC Futures assembly are no longer available once that version of ASP.NET MVC has gone RTM. 

All Loaded Assemblies 

71 assemblies are loaded. 

A_65e81fd0_eb37_47d8_aba0_baece822c7ad, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 
Antlr3.Runtime, Version=3.3.1.7705, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
App_global.asax.1h_47vyd, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 
App_Web_rnug5pva, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 
BasicAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
Microsoft.JScript, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
Microsoft.VisualBasic.Activities.Compiler, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
Microsoft.VisualStudio.Web.PageInspector.Runtime, Version=12.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
Microsoft.VisualStudio.Web.PageInspector.Tracing, Version=12.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed 
SMDiagnostics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Data.Services.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
System.Runtime.DurableInstancing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.RegularExpressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Workflow.ComponentModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Workflow.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.WorkflowServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
WebGrease, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
6

Mở packages.config trong dung dịch thám hiểm của bạn ..

Sau đó tìm kiếm ASP.NET MVC gói ID, như sau:

id = "Microsoft. AspNet.Mvc" version = "5.2.2" targetFramework = "net452"

4

Tại runtime-

string mvcVersion = typeof (Controller).Assembly.GetName().Version.ToString(); 

Tại thiết kế tốn nhiều thời gian

  • Tới thư mục tài liệu tham khảo của bạn
  • nhìn cho system.web.MVC
  • Right Click vào nó
  • Bấm Thuộc tính Nhìn vào các tài sản

Version.

+0

Tôi không hiểu lúc đầu trong cửa sổ 'Tạo dự án mới' ở trên mẫu asp được viết 4.6 nhưng bản tham chiếu MVC của tôi là phiên bản 5: | – AmiNadimi

Các vấn đề liên quan