0

我在我的 MVC 应用程序中使用了第 3 方 javascript。javascript 显示一个交互式日历,供用户通过鼠标单击输入日期和时间。

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. 
4

1 回答 1

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)
于 2012-08-14T22:15:35.873 回答