Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 15, 2012 02:00 PM by amcdermott
Jun 28, 2012 02:04 AM|LINK
I've built a little prototype application using MVC 4 RC and something very basic is broken. The following works in MVC 2 and MVC 3 without an issue. There are a number of differnet flavors, but the most basic is documented everywhere... This however does
NOT work in MVC 4
As described this should download the site.css file to the clients browser, and open it up with the appropriate application... This works perfectly in MVC 2 and MVC 3... In MVC 4 all you receive is content that reads "undefined". No error, and no way to
track the response... simply "undefined"... Yuck this was ugly!
Update... Um... I manually placed an anchor link to the same file... It also receives the same response from the server... "undefined"... Now I'm really confused... Is this a web server error, a .NET error... or??? Perhaps something in the web config file
specific to .net 4?
Jun 28, 2012 03:58 AM|LINK
Can you try running fiddler and see what is the response code and content you are getting from the server?
Jun 28, 2012 04:21 AM|LINK
I did as you requested... It is very odd! The in browser response is "undefined", but fiddler is reporting nothing wrong?
Fiddler is reporting that the entire file was downloaded... 1151 bytes... and I can certainly confirm the contents. However, the browser is reporting "undefined" is the response (I cannot see this in Fiddler). This occurs in multiple browsers (chrome, firefox,
I tried replacing the File(Server.MapPath("~/content/site.css"), "text/css")); with return Content("hello world");... Again, the browser is reporting "undefined" while fiddler text view and raw view report "hello world" text...
Jun 28, 2012 02:16 PM|LINK
So, I was really getting annoyed with the results I was getting. I can't believe that something so simple as returning "file" or "content" in an MVC 4 Mobile Application controller would have been missed. So... I downloaded and installed Microsoft Visual
Studio Express 2012 on a clean workstation. After the install I created 4 applications...
The result is; Dah, da, da , daaaa.... The problem exists in Mobile applications ONLY... Which happens to be what I am trying to build! CRAP!
Jun 28, 2012 09:41 PM|LINK
Might as well keep this current... Still waiting on some response... I believe I have isolated the problem...
Since the Controller "File" or "Content" returns were working in an MVC application, but not the MVC Mobile application I figured it had something to do with the MVC Mobile template... Something that was built into the later (or not included) that was in
the former... So, I started with the MVC Basic template and built my way up.
The controller continued to function for "content" and "file" returns right up until I started (re)placing all the css and js scripts into the BundlesConfig.cs file. The delta that broke things was the combination of the jquery.mobile css and js files...
first occured. A poster mentioned that I should run Fiddler and see what response I was getting... Of course, Fiddler said, "nothing to see here... everything is good!" That should have been my second clue... It had to be something outside of C#, .NET, etc...
Well, it appears that the jquery mobile js and css combination is the issue... now I have my real work cut out for me...
This is really more work than I need...
Jun 28, 2012 09:50 PM|LINK
Great, appriciate your work, you got lots of stuff figured out. I wish I could able to help but I have very limited knowledge on Mobile. I would request other expert to pitch in for your help.
Jun 28, 2012 11:52 PM|LINK
Hi stewart - I work on the ASP.NET MVC team. Using Visual Studio 2012 RC, I'm unable to reproduce the problem. The following code from the mobile template works fine for me:
return File(Server.MapPath("~/Content/Site.Css"), "text/css");
The file is downloaded.
Jun 29, 2012 12:52 AM|LINK
Rick... thanks for your response...
I am seeing this behavior in VS 2010 with SP1 and VS 2012 Express RC... I have tested it on more than one development workstation with more than one platform. This occurs in both VB and C# in both tools. I have isolated the problem to the JQuery Mobile js
and css files.
To determine the cause of the problem I started an MVC Basic application, and begain placing all the components to convert it to mobile. Everything remained functional right up until I got down to the bundling. Once I placed the jquery mobile js and css
I am also receiving the same issue when I place return Content("Hello World"); into the Controller... I have posted the issue on JQuery Mobile Site Forums as well. I can reproduce this in many ways and on many workstations. I would be happy to demonstrate
and provide whatever assistance to resolve this problem. Feel free to contact me in this regard. I would LOVE to solve this problem.
I ran one final test... I removed the mobile files from the bundle and placed the links directly in the _layout.cshtml file. Same result... so I'm not inclined to believe that this is anything with the MVC framework or .NET. I can reproduce this problem
outside of the MVC Controller as well... I placed an Anchor Tag with an HREF to the downloadable file.... I get EXACTLY the same behavior.
I would very much appreciate any input or testing that you could help provide. I can provide external access to a VM workstation that has RC 2012 Express and you can reproduce the problem for yourself to verify.
Looking forward to your response.
Jun 29, 2012 04:18 PM|LINK
It would be nice to know how you are getting this to work... other than "it works for me". Can you supply me with detail, like JQuery Mobile Version, ect... This simply is not working for me. I installed a clean version of Windows 7 Professional in a VM,
installed VS Express 2012 RC, and created the MVC Mobile C# Template project and I am getting the same behavior...
Can you respond with some detail, I'm really kind of stuck here!
Jun 29, 2012 04:43 PM|LINK
I wanted to zip up my project file and attach it, but it appears that this not possible here... So, here are my steps.
This MVC 4 Mobile Template appears to be using JQuery 1.64, JQuery UI 1.8.11, JQuery Mobile 1.0, as well as ubobtrusive... By Default the Template Project is set to use .NET Framework 4.5...