Question

I have a MVC2 website which uses views from other assemblies. To do this, I marked the view as "Embedded Resource".

I was able to see the view but now, when I change the view I can't see the changes anymore.

The way I call the view as an embedded resource is similar to this:

return View("~/Extension/Extensions.MyExtension.dll/" +
    "Extensions.MyExtension.Views.MyItem.Details.ascx", entity);

in this case the "Extension" part is indicating that the view must be loaded as embedded resource. The following part indicates the assemblies which contains the view. The last part is the location of the view (including namespace).

How can it be that data from an earlier view is still shown after I change the entire content of the view. Or even unmark the view as embedded resource.

To make sure I have the latest assembly of Extensions.myExtension.dll I copied the assembly to the bin folder of the website. I checked the assembly with reflector to see if the correct view is in the assembly. This is the correct view but I still see the old view.

Changing the name of the view resolves the problem temporary, but is not I good solution for me. When I change name of the view back to what is was, the old view was shown.

Was it helpful?

Solution

Almost seems to me if data is cached and the DLL files aren't being seen as changed. Do you have the property 'optimizeCompilations' in your web.config? Check if it's set to false. Otherwise (if true) only changed DLL-files are recompiled.

More information can be found on this MSDN page.

For example:

<compilation debug="true" defaultLanguage="c#" targetFramework="4.0"
    optimizeCompilations="false">

OTHER TIPS

You might need to recompile the project because views are embedded into the resulting assembly at compile time. If you simply change the ASCX file without recompiling changes won't take effect if you simply refresh your browser.

You need to rebuild your complete project. If that also doesn't solve the problem, Clean the project and then build.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top