Category Archives: ASP.Net MVC

ASP.Net and Web Tool 2.2 Download

ASP.Net and Web Tool 2.2 終於Release 了




  • Page Inspector
  • Editor
    • Support syntax highlighting for CoffeeScript, Mustache, Handlebars, and JsRender.
    • The HTML editor provides Intellisense for Knockout bindings.
    • LESS editing and compiler support to enable building dynamic CSS using LESS.
    • Paste JSON as a .NET class. Using this Special Paste command to paste JSON into a C# or VB.NET code file, and Visual Studio will automatically generate .NET classes inferred from the JSON.
  • Mobile Emulator support adds extensibility hooks so that third-party emulators can be installed as a VSIX. The installed emulators will show up in the F5 dropdown, so that developers can preview their websites on a variety of mobile devices. Read more about this feature in Scott Hanselman’s blog entry on the new BrowserStack integration with Visual Studio.

Web Publishing

  • Web site projects now have the same publishing experience as Web Application projects including publishing to Windows Azure Web Sites.
  • Selective publish – for one or more files you can perform the following actions (after publishing to a Web Deploy endpoint):
    • Publish selected files.
    • See the difference between a local file and a remote file.
    • Update the local file with the remote file or update the remote file with the local file.

ASP.NET MVC Templates

  • The new Facebook Application template makes writing Facebook Canvas applications easy. In a few simple steps, you can create a Facebook application that gets data from a logged in user and integrates with their friends. The template includes a new library to take care of all the plumbing involved in building a Facebook app, including authentication, permissions, accessing Facebook data and more. For more information on using the Facebook Application template see
  • A new Single Page Application MVC template allows developers to build interactive client-side web apps using HTML 5, CSS 3, and the popular Knockout and jQuery JavaScript libraries, on top of ASP.NET Web API. The template includes a “todo” list application that demonstrates common practices for building a JavaScript HTML5 application that uses a RESTful server API. You can read more at
  • You can now create a VSIX that adds new templates to the ASP.NET MVC New Project dialog. Learn how here:
  • FixedDisplayModes package – MVC project templates have been updated to include the new ‘FixedDisplayModes’ NuGet package, which contains a workaround for a bug in MVC 4. For more information on the fix contained in the package, refer to this blog post ( from the MVC team.


ASP.NET Web API has been enhanced with several new features:

  • ASP.NET Web API OData
  • ASP.NET Web API Tracing
  • ASP.NET Web API Help Page


ASP.NET Web API OData gives you the flexibility you need to build OData endpoints with rich business logic over any data source. With ASP.NET Web API OData you control the amount of OData semantics that you want to expose. ASP.NET Web API OData is included with the ASP.NET MVC 4 project templates and is also available from NuGet (

ASP.NET Web API OData currently supports the following features:

  • Enable OData query semantics by applying the [Queryable] attribute.
  • Easily validate OData queries and restrict the set of supported query options, operators and functions.
  • Parameter bind to ODataQueryOptions directly to get an abstract syntax tree representation of the query that can then be validated and applied to an IQueryable or IEnumerable.
  • Enable service-driven paging and next page link generation by specifying result limits on [Queryable] attribute.
  • Request an inlined count of the total number of matching resources using $inlinecount.
  • Control null propagation.
  • Any/All operators in $filter.
  • Infer an entity data model by convention or explicitly customize a model in a manner similar to Entity Framework Code-First.
  • Expose entity sets by deriving from EntitySetController.
  • Simple, customizable conventions for exposing navigation properties, manipulating links and implementing OData actions.
  • Simplified routing using the MapODataRoute extension method.
  • Support for versioning by exposing multiple EDM models.
  • Expose service document and $metadata so you can generate clients (.NET, Windows Phone, Windows Store, etc.) for your Web API.
  • Support for the OData Atom, JSON, and JSON verbose formats.
  • Create, update, partially update (PATCH) and delete entities.
  • Query and manipulate relationships between entities.
  • Create relationship links that wire up to your routes.
  • Complex types.
  • Entity Type Inheritance.
  • Collection properties.
  • Enums.
  • OData actions.
  • Built upon the same foundation as WCF Data Services, namely ODataLib (

For more information on ASP.NET Web API OData see

ASP.NET Web API Tracing

ASP.NET Web API Tracing integrates tracing data from your web APIs with .NET Tracing. It is now enabled by default in the Web API project template. Tracing data for your web APIs is sent to the Output window and is made available through IntelliTrace. ASP.NET Web API Tracing enables you to trace information about your Web API when hosted on Windows Azure through integration with Windows Azure Diagnostics. You can also install and enable ASP.NET Web API Tracing in any application using the ASP.NET Web API Tracing NuGet package (

For more information on configuring and using ASP.NET Web API Tracing see

ASP.NET Web API Help Page

The ASP.NET Web API Help Page is now included by default in the Web API project template. The ASP.NET Web API Help Page automatically generates documentation for web APIs including the HTTP endpoints, the supported HTTP methods, parameters and example request and response message payloads. Documentation is automatically pulled from comments in your code. You can also add the ASP.NET Web API Help Page to any application using the ASP.NET Web API Help Page NuGet package (

For more information on setting up and customizing the ASP.NET Web API Help Page see


ASP.NET SignalR makes it simple to add real-time web capabilities to your ASP.NET application, using WebSockets if available and automatically falling back to other techniques when it isn’t.

For more information on using ASP.NET SignalR see

ASP.NET Friendly URLs

ASP.NET FriendlyURLs makes it very easy for web forms developers to generate cleaner looking URLs(without the .aspx extension). It requires little to no configuration and can be used with existing ASP.NET v4.0 applications. The FriendlyURLs feature also makes it easier for developers to add mobile support to their applications, by supporting switching between desktop and mobile views.

For more information on installing and using ASP.NET Friendly URLs see

有關新功能可以到以下URL 參考

Hope you find it useful website did not work on ie10 FIXED – 用戶使用IE10在不能登入ASP.Net 的網頁 SCRIPT5009P ‘__doPostBack’ is undefined

今天有客戶投訢當他們更新了他們的IEIE10之後 不能登入到公司的ASP.Net 網頁
當我便用IE10 去登入公司的網頁時… 在Developer ToolConsole上出現了以下的錯誤信息
SCRIPT5009P ‘__doPostBack’ is undefined
SCRIPT5009P '__doPostBack' is undefined

做了一會兒research 之後終生找到了解決方法

我們可以到以下的URL 去Request 這一個Hotfix
A hotfix is available for the ASP.NET browser definition files in the Microsoft .NET Framework 4.0

.NET Framework 4.0 – Windows XP, Windows 2003, Windows Vista, Windows Server 2008, Win7, Windows Server 2008 R2 (MSI)

按了”Hotfix Download Available“之後便會轉到另外一個頁面..
A hotfix is available for the ASP.NET browser definition files in the Microsoft .NET Framework 4.0
填上電郵..之後便會把Hotfix的Download Link發送到你的電郵..
 photo HotFix2600088.jpg

Hope you find it useful

JQuery get number of items inside select list/ dropdownlist – 使用JQuery來取得在SelectList/ DropDownList上有多小個Item.

今天公司的ASP.Net MVC Website其中有一個Form 有很多Dynamic的 資料要取出

不能Populate 其他的DropDownList



int NumberOfItems = ddl.Items.Count;

但是在ASP.Net MVC上我們便需要使用JQuery來實現了
假設我們的DropDownList 是這樣的

<select id="MinimumContractTerm" name="MinimumContractTerm" class="valid"><option value="1">1 month</option>
<option value="3">3 months</option>
<option value="6">6 months</option>
<option value="12">12 months - 1 Year</option>
<option value="24">24 months - 2 Year</option>
<option value="36">36 months - 3 Year</option>
<option value="48">48 months - 4 Year</option>
<option value="60">60 months - 5 Year</option>
<button id="btn_run" name="btn_run">Run</button>

我們可以使用以下的JQuery 方法來解決這個問題

 $(document).ready(function () {

Hope you find it useful

Visual Studio 2010 Could not load ASP.Net MVC Project – VS2010不能開啟ASP.Net MVC 的Project

今天同事開始學習寫ASP.Net MVC 3的Website

誰不知..當他從TFS 取後Project卻出現以下的錯誤信息
One or more projects in the solution were not loaded correctly. Please see te Output Windows for details
One or more projects in the solution were not loaded correctly. Please see te Output Windows for details

當我查看 “Output Windows/輸出視窗” 時出現了以下的信息
The project type is not supported by this installation.
The project type is not supported by this installation.
是因為他沒有在電腦上安裝ASP.Net MVC3的元件
大家可以到ASP.Net 的網頁上Download.
ASP.Net Website Download ASP.Net MVC
Install ASP.Net MVC 3 via Web PI
Happy Coding

ASP.Net MVC Javascript Alert ViewBag value

今天需要做用JavascrptAlert function 來彈出一些提示信息姶用戶..
而這些信息是Store 在ASP.Net MVCViewBag上…
怎樣才可以在Javascrript上使用Alert來輸出 ViewBag的內容呢?


<script type="text/javascript">
var AlertMessage = '@(ViewBag.ShareChiWaiMessage)';

Hope you find it useful