[Mono-dev] Bug in mono 3.0.1 MVC3 File/FileResult
SirNoSkill
quandary82 at hailmail.net
Tue Jan 29 15:59:59 UTC 2013
There is a bug in mono 3.0.1.
I don't know if it is fixed in 3.0.3
If in a asp.net MVC3 controller, I call File via path (probably uses
FilePathResult)
like this
http://www.daniel-steiger.ch/gallery/FullImage/001.jpg?no_cache=1358694795000
I get the image data as text.
The path is correct.
The mime is correct.
The image itselfs is valid.
If I call the url to the image directly and not via the "File" method,
then it works
Proof:
http://www.daniel-steiger.ch/Content/images/gallery/002.jpg?LastWriteTimeUTC=1358694795000
Ironically, generating the thumbnail works (that probably goes via
FileStreamResult).
Both work correctly on windows.
PS:
The latest-stable install script for xsp misses copying
fastcgi-mono-server4, mod-mono and xsp to the 4.5 gac.
Same things applies to Microsoft.VisualBasic.dll.
See here:
http://stackoverflow.com/questions/4239645/does-the-razor-view-engine-work-for-mono
namespace Homepage.Controllers
{
public class GalleryController : Controller
{
protected static string GetImageDirectory()
{
string bd = AppDomain.CurrentDomain.BaseDirectory;
string strImageDirectory = System.IO.Path.Combine(bd,
"Content");
strImageDirectory =
System.IO.Path.Combine(strImageDirectory, "images");
strImageDirectory =
System.IO.Path.Combine(strImageDirectory, "gallery");
return strImageDirectory;
} // End Function GetImageDirectory
protected static string strImageDirectory = GetImageDirectory();
public FileResult FullImage(string id)
{
string strFileName =
System.IO.Path.Combine(strImageDirectory, id);
//return new FilePathResult("CorrectFullPathAndFileName",
"CorrectMime");
return File(strFileName, "image/jpg");
} // End Action FullImage
public FileResult Thumb(string id)
{
//return Redirect(id);
string strFileName =
System.IO.Path.Combine(strImageDirectory, id);
System.IO.Stream ms =
Tools.Imaging.GetThumbnailStream(strFileName,
System.Drawing.Imaging.ImageFormat.Png);
return File(ms, "image/png");
/*
using (System.IO.Stream ms =
Tools.Imaging.GetThumbnailStream(strFileName,
System.Drawing.Imaging.ImageFormat.Png))
{
return File(ms, "image/png");
}*/
} // End Action Thumb
} // End Class GalleryController : Controller
} // End Namespace Homepage.Controllers
--
SirNoSkill
quandary82 at hailmail.net
--
http://www.fastmail.fm - Email service worth paying for. Try it for free
More information about the Mono-devel-list
mailing list