【茶包射手日記】在SPS2007站台安裝ASP.NET MVC4
0 |
應專案需求在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>
以上經驗供參。
Comments
Be the first to post a comment