[Mono-bugs] [Bug 670874] New: Incorrect result of WebFormViewEngine.FileExists with MVC 3 & precompilled site

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Feb 10 03:38:39 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=670874

https://bugzilla.novell.com/show_bug.cgi?id=670874#c0


           Summary: Incorrect result of WebFormViewEngine.FileExists with
                    MVC 3 & precompilled site
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.10.x
          Platform: x86
        OS/Version: Windows 7
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Web
        AssignedTo: mhabersack at novell.com
        ReportedBy: ilya.lukyanov at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7

I have downloaded latest Mono 2.10 and released MVC Framework 3.0. Then i've
created a simple MVC solution in MonoDevelop from template and replaced MVC 2.0
reference with MVC 3.0, added System.Web.WebPages as reference and changed my
project's runtime to .NET 4.0.

After that i've used aspnet_compiler from Microsoft .NET 4.0 to precompile my
site with command aspnet_compiler.exe -v "/" -p C:\MySite C:\MyPrecompiledSite

Then i made it run under xsp4 and got an error telling me that no view was
found in:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
etc.

Finally i've figured out the problem.
The problem is in BuildManager.GetObjectFactory behavior

System.Web.Compilation.BuildManager.GetObjectFactory("~/Views/Home/Index.aspx",
false) == null //true
System.Web.Compilation.BuildManager.GetObjectFactory("/Views/Home/Index.aspx",
false) == null //false

So without "~" it successfully finds a view.

it was tested with custom view engine that is a proxy over WebFormViewEngine
and looks like this:

public class MyViewEngine : VirtualPathProviderViewEngine
{
   private WebFormViewEngine _eng;
   public VE() : this(null) {...}
   public VE(IViewPageActivator a) : base()  {...}

   protected override bool FileExists (ControllerContext controllerContext,
string virtualPath)
   {
      virtualPath = virtualPath.Replace("~", "");
      return (bool) _eng.GetType().GetMethod("FileExists",
BindingFlags.Instance | BindingFlags.NonPublic)
         .Invoke(_eng, new object[] { controllerContext, virtualPath});
   }        
}

Registering this view engine solves a problem.

The reason, i think, is in the way a virtualPath is written in *.compiled
files.
For example:
<preserve resultType="3" virtualPath="/Views/Home/Index.aspx" ...>
  <filedeps>
    <filedep name="/Views/Home/Index.aspx" />
  </filedeps>
</preserve>


P.S. I'm not sure if this is important but i have a custom virtual path
provider registered on Application_Start in Global.asax.cs with
HostingEnvironment.RegisterVirtualPathProvider (myVpp);

Reproducible: Always

Steps to Reproduce:
1.Create a MVC project in MonoDevelop from template
2.Change System.Web.Mvc.dll reference to it's 3.0 version, add
System.Web.WebPages reference
3.Change runtime to 4.0
4.Precompile a project with aspnet_compiler
5.Run it with xsp4
Actual Results:  
error telling that no view was found in:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
etc.

Expected Results:  
White page

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list