我已经阅读了几乎所有关于此的问题,但没有找到解决方案。我收到的错误是500 Internal Service Error
,指出了一个特定的错误:CS0103: The name 'ViewBag' does not exist in the current context.
奇怪的是,只有在进行ajax
调用时才会出现此错误。如果没有涉及ajax调用,则相同的cshtml
页面工作正常。
以下是两个响应,其中一个有效(第一个),另一个失败(第二个):
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4
Cache-Control:no-cache
Connection:keep-alive
Host:localhost
Pragma:no-cache
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
Response Headersview source
Access-Control-Allow-Origin:Access-Control-Allow-Origin
Cache-Control:private
Content-Encoding:gzip
Content-Length:7033
Content-Type:text/html; charset=utf-8
Date:Mon, 10 Feb 2014 19:25:49 GMT
Server:Microsoft-IIS/7.5
Vary:Accept-Encoding
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:3.0
Request Method:GET
Status Code:500 Internal Server Error
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4
Cache-Control:no-cache
Connection:keep-alive
Host:localhost
Pragma:no-cache
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
X-Requested-With:XMLHttpRequest
Query String Parametersview sourceview URL encoded
quarter:1
year:1
Response Headersview source
Access-Control-Allow-Origin:Access-Control-Allow-Origin
Cache-Control:private
Content-Length:48466
Content-Type:text/html; charset=utf-8
Date:Mon, 10 Feb 2014 19:28:29 GMT
Server:Microsoft-IIS/7.5
X-AspNet-Version:4.0.30319
请帮忙!