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
Start a new MVC 4 project.
Remark out return View() from the About HomeController (this could be any controller that is wired up).
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!
Stew Basterash
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?
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,
ie9).
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...
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...
Visual Basic Web Application - MVC 4 Internet Application - WORKING
Visual Basic Web Application - MVC 4 Mobile Application - BROKEN
C# Web Application - MVC 4 Internet Application - WORKING
C# Web Application - MVC 4 Mobile Application - BROKEN
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!
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...
My _layout file looked great at that point, but I started getting the "undefined" response right at that point... (again... I have worked with javascript for so long that should have been my first clue) Which goes along with what I was stating when the problem
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...
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.
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:
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
files into the App_Start, "BundlesConfig.cs" file and recompiled, the error returned. Fiddler returns no errors, and in fact the response contains the data/file in question... the browser on the other hand responds with "undefined"... This is definately javascript
response.
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.
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!
I wanted to zip up my project file and attach it, but it appears that this not possible here... So, here are my steps.
On a clean Windows 7 Professional Workstation (with all the necessary patches up to date and the latest .net framework installed)
Install Visual Studio Express RC 2012.
Start a C# (or VB), web project, MVC 4 Mobile (only) Template.
Name the project "testDownload".
VS churns away.... Project Comes up with Home Controller source showing...
Change the About() view on the Home controller by remarking out the ViewBag and return View() lines.
Replace those lines of code with simply return File(Server.MapPath("~/content/site.css"), "text/css"); or return Content("Any Text");
Compile and Run...
Click on About Button... Response from server is a completely blank browser with "undefined" in the upper left corner as if you were attempting to return Content("undefined")... Which by the way does NOT work either.
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...
stewart.bast...
0 Points
16 Posts
MVC 4 File ActionResult broken
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!
Stew Basterash
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?
CPrakash82
All-Star
18168 Points
2833 Posts
Re: MVC 4 File ActionResult broken
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?
Thanks,
stewart.bast...
0 Points
16 Posts
Re: MVC 4 File ActionResult broken
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, ie9).
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...
Any thoughts?
stewart.bast...
0 Points
16 Posts
Re: MVC 4 File ActionResult broken
Jun 28, 2012 02:16 PM|LINK
More review...
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!
stewart.bast...
0 Points
16 Posts
Re: MVC 4 File ActionResult broken
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... My _layout file looked great at that point, but I started getting the "undefined" response right at that point... (again... I have worked with javascript for so long that should have been my first clue) Which goes along with what I was stating when the problem 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...
CPrakash82
All-Star
18168 Points
2833 Posts
Re: MVC 4 File ActionResult broken
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.
Thanks,
ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: MVC 4 File ActionResult broken
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.
stewart.bast...
0 Points
16 Posts
Re: MVC 4 File ActionResult broken
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 files into the App_Start, "BundlesConfig.cs" file and recompiled, the error returned. Fiddler returns no errors, and in fact the response contains the data/file in question... the browser on the other hand responds with "undefined"... This is definately javascript response.
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.
Stew Basterash
stewart.bast...
0 Points
16 Posts
Re: MVC 4 File ActionResult broken
Jun 29, 2012 04:18 PM|LINK
Rick,
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!
Stew
stewart.bast...
0 Points
16 Posts
Re: MVC 4 File ActionResult broken
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...
Thoughts?