javascript
  • asp.net-mvc
  • 2012-08-10 83 views 0 likes 
    0

    我在我的MVC應用程序中使用第三方JavaScript。 javascript顯示交互式日曆,供用戶從鼠標單擊輸入日期和時間。JavaScript事件被激活爲ASP.net MVC控制器動作

    vCalTime+="<td align='center'><table cellspacing='0' cellpadding='0' style='line-height:0pt'><tr><td><img onmousedown='startSpin(\"Hour\", \"plus\");' onmouseup='stopSpin();' src='../../images/cal_plus.gif' width='13px' height='9px' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td></tr><tr><td><img onmousedown='startSpin(\"Hour\", \"minus\");' onmouseup='stopSpin();' src='../../images/cal_minus.gif' width='13px' height='9px' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td></tr></table></td>\n"; 
    

    奇怪的是,只有在IIS7,日曆中的所有導航是由MVC路由引擎控制器的方法,但是從用戶機器的頁面和日曆做工精細抓獲。只是我收到了很多ELMAH的電子郵件通知。我可以過濾錯誤,但我只是想知道這是否真的是一個錯誤。以下是被ELMAH困住的東西。有誰知道什麼可能會導致問題?謝謝。

    System.Web.HttpException: A public action method 'images' was not found on controller 'MYAPP.Controllers.ControllerNameController'. 
    Generated: Fri, 10 Aug 2012 16:11:13 GMT 
    
    System.Web.HttpException (0x80004005): A public action method 'images' was not found on controller 'MYAPP.Controllers.ControllerNameController'. 
        at System.Web.Mvc.Controller.HandleUnknownAction(String actionName) 
        at System.Web.Mvc.Controller.ExecuteCore() 
        at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__4() 
        at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0() 
        at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
        at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 
    
    Server Variables 
    Name Value 
    **ALL_HTTP** HTTP_CONNECTION:Keep-Alive HTTP_ACCEPT:*/* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:en-us HTTP_AUTHORIZATION:Negotiate TlRMTVNTUAADAAAAGAAYAIAAAADMAMwAmAAAAAoACgBIAAAAGAAYAFIAAAAWABYAagAAAAAAAABkAQAABYKIogUBKAoAAAAPVgBIAEEAMgAwAFYASABBAFAATwBSAFQARQBFAE4AWQBUAFAATwBSAC0AVwBTADkANwA3ADMAMQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADPBnHWzuV8BTujt2KHowUjAQEAAAAAAAAIhjfDEnfNAQz9aC9ImrcDAAAAAAIABgBSADAAMQABABYAUgAwADEAUABPAFIAVwBFAEIAMAA1AAQAHAByADAAMQAuAG0AZQBkAC4AdgBhAC4AZwBvAHYAAwA0AFIAMAAxAFAATwBSAFcARQBCADAANQAuAHIAMAAxAC4AbQBlAGQALgB2AGEALgBnAG8AdgAFAAwAdgBhAC4AZwBvAHYABwAIAAiGN8MSd80BAAAAAAAAAAA= HTTP_COOKIE:ASP.NET_SessionId=ar4sal4yoyuynber4e0gaanm HTTP_HOST:HostingServer 
    **HTTP_REFERER**: HostingServer/MYAPP/ControllerName/Create/99999999/NoneOfTheAbove HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; MS-RTC LM 8; .NET4.0E) HTTP_UA_CPU:x86 
    **ALL_RAW** Connection: Keep-Alive Accept: */* Accept-Encoding: gzip, deflate Accept-Language: en-us Authorization: Negotiate TlRMTVNTUAADAAAAGAAYAIAAAADMAMwAmAAAAAoACgBIAAAAGAAYAFIAAAAWABYAagAAAAAAAABkAQAABYKIogUBKAoAAAAPVgBIAEEAMgAwAFYASABBAFAATwBSAFQARQBFAE4AWQBUAFAATwBSAC0AVwBTADkANwA3ADMAMQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADPBnHWzuV8BTujt2KHowUjAQEAAAAAAAAIhjfDEnfNAQz9aC9ImrcDAAAAAAIABgBSADAAMQABABYAUgAwADEAUABPAFIAVwBFAEIAMAA1AAQAHAByADAAMQAuAG0AZQBkAC4AdgBhAC4AZwBvAHYAAwA0AFIAMAAxAFAATwBSAFcARQBCADAANQAuAHIAMAAxAC4AbQBlAGQALgB2AGEALgBnAG8AdgAFAAwAdgBhAC4AZwBvAHYABwAIAAiGN8MSd80BAAAAAAAAAAA= Cookie: ASP.NET_SessionId=ar4sal4yoyuynber4e0gaanm Host: HostingServer 
    **Referer**: HostingServer/MYAPP/ControllerName/Create/99999999/NoneOfTheAbove User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; MS-RTC LM 8; .NET4.0E) UA-CPU: x86 
    **APPL_MD_PATH** /LM/W3SVC/2/ROOT/MYAPP 
    **APPL_PHYSICAL_PATH** E:\HostingServer\MYAPP\ 
    **AUTH_TYPE** Negotiate 
    **AUTH_USER** DOMAIN\USERNAME 
    **AUTH_PASSWORD**  
    **LOGON_USER** DOMAIN\USERNAME 
    **REMOTE_USER** DOMAIN\USERNAME 
    **CERT_COOKIE** 
    **CERT_FLAGS** 
    **CERT_ISSUER** 
    **CERT_KEYSIZE**  
    **CERT_SECRETKEYSIZE** 
    **CERT_SERIALNUMBER**  
    **CERT_SERVER_ISSUER** 
    **CERT_SERVER_SUBJECT** 
    **CERT_SUBJECT**  
    **CONTENT_LENGTH** 0 
    **CONTENT_TYPE**  
    **GATEWAY_INTERFACE** CGI/1.1 
    **HTTPS** off 
    **HTTPS_KEYSIZE**  
    **HTTPS_SECRETKEYSIZE** 
    **HTTPS_SERVER_ISSUER** 
    **HTTPS_SERVER_SUBJECT**  
    **INSTANCE_ID** 2 
    **INSTANCE_META_PATH** /LM/W3SVC/2 
    **LOCAL_ADDR** 10.165.50.180 
    **PATH_INFO** /MYAPP/ControllerName/images/cal_minus.gif 
    **PATH_TRANSLATED** E:\HostingServer\MYAPP\ControllerName\images\cal_minus.gif 
    **QUERY_STRING**  
    **REMOTE_ADDR** 10.10.60.17 
    **REMOTE_HOST** 10.10.60.17 
    **REMOTE_PORT** 3410 
    **REQUEST_METHOD** GET 
    **SCRIPT_NAME** /MYAPP/ControllerName/images/cal_minus.gif 
    **SERVER_NAME** HostingServer 
    **SERVER_PORT** 80 
    **SERVER_PORT_SECURE** 0 
    **SERVER_PROTOCOL** HTTP/1.1 
    **SERVER_SOFTWARE** Microsoft-IIS/7.5 
    **URL** /MYAPP/ControllerName/images/cal_minus.gif 
    **HTTP_CONNECTION** Keep-Alive 
    **HTTP_ACCEPT** */* 
    **HTTP_ACCEPT_ENCODING** gzip, deflate 
    **HTTP_ACCEPT_LANGUAGE** en-us 
    **HTTP_AUTHORIZATION** Negotiate TlRMTVNTUAADAAAAGAAYAIAAAADMAMwAmAAAAAoACgBIAAAAGAAYAFIAAAAWABYAagAAAAAAAABkAQAABYKIogUBKAoAAAAPVgBIAEEAMgAwAFYASABBAFAATwBSAFQARQBFAE4AWQBUAFAATwBSAC0AVwBTADkANwA3ADMAMQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADPBnHWzuV8BTujt2KHowUjAQEAAAAAAAAIhjfDEnfNAQz9aC9ImrcDAAAAAAIABgBSADAAMQABABYAUgAwADEAUABPAFIAVwBFAEIAMAA1AAQAHAByADAAMQAuAG0AZQBkAC4AdgBhAC4AZwBvAHYAAwA0AFIAMAAxAFAATwBSAFcARQBCADAANQAuAHIAMAAxAC4AbQBlAGQALgB2AGEALgBnAG8AdgAFAAwAdgBhAC4AZwBvAHYABwAIAAiGN8MSd80BAAAAAAAAAAA= 
    **HTTP_COOKIE** ASP.NET_SessionId=ar4sal4yoyuynber4e0gaanm 
    **HTTP_HOST** HostingServer 
    **HTTP_REFERER** HostingServer/MYAPP/ControllerName/Create/99999999/NoneOfTheAbove 
    
    **HTTP_USER_AGENT** Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; MS-RTC LM 8; .NET4.0E) 
    **HTTP_UA_CPU** x86 
    
    
    Powered by ELMAH, version 1.1.11517.2009 (debug; RC; net-3.5). Copyright (c) 2004-9, Atif Aziz. All rights reserved. Licensed under Apache License, Version 2.0. 
    

    回答

    0

    問題已解決。 js腳本使用日曆中用作導航按鈕的圖像的相對路徑。當應用程序部署在另一臺服務器上時,使用相對路徑找不到映像文件。我創造了的Site.Master一個javascript全局變量作爲

    <script type="text/javascript"> 
        var appRoot = '<%:Url.Content("~/")%>' 
    </script> 
    

    ,並在.js文件我用它來代替硬編碼的相對路徑(../)的。

    vCalHeader += "<td><img onmousedown='javascript:Cal.DecYear();RenderCssCal();' src='" + appRoot + "images/cal_fastreverse.gif' width='13px' height='9' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td>\n"; //Year scroller (decrease 1 year) 
    
    相關問題