【茶包射手日記】在SPS2007站台安裝ASP.NET MVC4

應專案需求在SPS2007網站安裝ASP.NET MVC4,建立Web Application,設好萬用字元應用程式對應(IIS6之特殊需求,可參考保哥文章常見問題3),執行MVC網頁時出現權限錯誤:

Server Error in '/MyMVC' Application.
--------------------------------------------------------------------------------

Could not find permission set named 'ASP.Net'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Configuration.ConfigurationErrorsException: Could not find permission set named 'ASP.Net'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[ConfigurationErrorsExc
eption: Could not find permission set named 'ASP.Net'.]
   System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +378

[HttpException (0x80004005): Could not find permission set named 'ASP.Net'.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9171632
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258

想起因為SPS要開放使用者外掛Web Part套件,為防止權限過大闖禍,Sharepoint有一套自訂的Trust Level原則。當ASP.NET MVC安裝在Sharepoint站台下,會繼承該設定,故在ASP.NET MVC web.config / <system.web> 加上<trust level="Full" />,以上問題即消失,但/controller/action路由仍為失效狀態,持續傳回HTTP 404。

爬文找到相關文章,其做法是同時修改Sharepoint及MVC的web.config,但經測試,我只在MVC web.config加上httpModules UrlRoutingModule設定路由就OK了!

<system.web>
  <trust level="Full" />
  <httpModules>
    <add name="UrlRoutingModule" 
type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=4.0.0.0, 
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  </httpModules>
</system.web>

以上經驗供參。

歡迎推文分享:
Published 03 December 2014 03:33 PM 由 Jeffrey
Filed under: ,
Views: 4,251



意見

沒有意見

你的看法呢?

(必要的) 
(必要的) 
(選擇性的)
(必要的) 
(提醒: 因快取機制,您的留言幾分鐘後才會顯示在網站,請耐心稍候)

5 + 3 =

搜尋

Go

<December 2014>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
 
RSS
創用 CC 授權條款
【廣告】
twMVC

Tags 分類檢視
關於作者

一個醉心技術又酷愛分享的Coding魔人,十年的IT職場生涯,寫過系統、管過專案, 也帶過團隊,最後還是無怨無悔地選擇了技術鑽研這條路,近年來則以做一個"有為的中年人"自許。

文章典藏
其他功能

這個部落格


Syndication