MVC3/Razor: cshtml.Execute()': no suitable method found to override - asp.net-mvc-3

I am trying to convert an MVC2 site to MVC3 using RazorViewEngine.
I used this tool to upgrade my project and the Telerik converter tool to convert my .aspx views to Razor. The Telerik tool put an #inherits line at the top of my layouts (inherting from ViewMasterPage).
When I tried to run a page that used one of these layouts, I got the error:
...cshtml.Execute(): no suitable method found to override
I removed the #inherits tag and it started to work for my home page. However, I continued to get this error for another page using the same layout. And now, after moving some things around to deal with an Areas issue, I'm back to getting this error for all my pages (the ones I can get to, anyway).
I have tried closing Visual Studio, deleting temporary files, etc.

Figured it out - the following section needs to be in the web.config for razor - I had it in the web.configs in the Views directories, but not in the root web.config:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>

There could be a few things going on here. Make sure you are following these guidelines
you don't have #inherits directives in your views. unless you are using a custom view page base class they are unnecessary. For strongly-typed views you should use the #model directive to specify the model type. For weekly-typed views you don't need anything.
don't mix razor views with aspx master pages (or aspx pages with razor layouts), as they don't work together easily. This includes checking all of your action methods where you have code like return View("ViewName", "MasterName") since that might also cause conflicting templatign technologies to be used.

If you still have a backup of your MVC2 project I would try using the tool Microsoft released on MSDN for this. See this link for more information. Also Scott Guthrie wrote something about it in his blog posts when MVC3 was released, you can read the article here.
I'm afraid I can't give you an direct solution to this. But sounds like an bug or problem in the conversion software from telerik you used.

Related

Prevent redirect to site.mobile.master

When I run the web form template of Visual Studio 2013 on a mobile phone the master page is redirected to Site.Mobile.master by default. Is there any way to prevent this and how???
THANKS
you can fool the application adding the code below in your web.config inside
<system.web>
<browserCaps>
<result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<filter>isMobileDevice=false</filter>
</browserCaps>
</system.web>
The code should be placed within the <system.web> tag. Your web.config file may already contain the tag, so can be placed in the existing one.

Telerik Controls Not working on IIS 7.5

I am developing a telerik Asp.net Ajax project using .net 4.5 and vs 2012. My development environment is working great however when I deploy my app on IIS 7.5 my default.aspx screen that contains 3 radcomboboxes and a radgrid is not working at all. When I say its not working the comboboxes are not dropping down and the radgrid controls are not responding. However when I replace one of the comboboxes with a Microsoft Dropdown I get the expected control behavior. I'am not sure what is causing this.Any ideas or suggestion will be highly appreciated.
These are my handlers in web.config.
<handlers>
<add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource"/>
<add name="Telerik.ReportViewer.axd_*" path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=6.1.12.823, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" preCondition="integratedMode"/>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</handlers>
WebResource.axd file which contains all the resources pertaining to Telerik is not getting loaded on runtime. That's the reason you see an unexpected behavior. Make sure that following httphandler exist in your web config file.
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false"/>
Refer to the following link for more help.
http://www.telerik.com/help/aspnet-ajax/introduction-web-resources-troubleshooting.html
I would also advice that if you are not using authentication in your app and if there are lines related to it exist in your web config, get rid of them.
I have managed to resolve this by removing the property UpdatePanelsRenderMode = "Inline" from inside my RadAjaxManager. This property if is set to inline places the contents inside html spans and for some reason the WS did not like it.

What Are the Correct Web.Config Settings for the VS2010 F# Compiler?

I've got an ASPX page like this:
<%# Page Language="F#" %>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<%-- Try to output "This is a Test" 10 times --%>
<% for i = 1 To 10 do %>
<p>This is a test</p>
</body>
</html>
and a web.config that looks like this:
<?xml version="1.0"?>
<configuration>
<system.codedom>
<compilers>
<compiler language="F#;f#;fs;fsharp"
extension=".fs"
warningLevel="4"
type="Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider,
FSharp.Compiler.CodeDom, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=a19089b1c74d0809">
<providerOption name="CompilerVersion" value="v4.0" />
<providerOption name="WarnAsError" value="false" />
</compiler>
</compilers>
</system.codedom>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>
When I run my VS2010 WebApp, I get an error like this:
"The CodeDom provider type "Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider,
FSharp.Compiler.CodeDom, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=a19089b1c74d0809" could not be located."
I've tried the settings mentioned by manojlds here, but they don't seem to be working for me either. I think it is because my copy of VS2010 Pro has a newer version of the F# compiler, but I don't know how to tell for sure.
Can someone help me understand the correct version settings that I should use in a VS2010 web.config for the "compiler" and "providerOption" elements?
I have not tried this, but your configuration file looks correct to me - can you check what eversion of the FSharp.Compiler.CodeDom assembly is installed in your GAC (by looking at C:\windows\assembly)?
However, at the moment, I would not really recommend using F# for writing of the ASPX part of a web page. It works, but you won't get as smooth experience when mixing C# with ASPX or using the Razor templating engine (for ASP.NET MVC).
I think the best way to create server-side ASP.NET web applications in F# is to use F# for the code behind (in traditional WebForms) or for the model and controller parts (in MVC). There is also a number of templates and tutorials that describe how to do this:
Tutorial: Creating a Web Project in F# Using an Online Template
and templates for ASP.NET MVC 4 and older ASP.NET MVC 3
You might also want to check out the Web Stacks page on fsharp.org

Why Do we need to change the handlers in web.config while using the telerik controls

I have a question, as on why do we need to add handelers to web.config file while working with telerik controls
what is the significance of the following code?
<system.web>
<httpHandlers>
<add verb="GET,HEAD" path="asset.axd" validate="false" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc" />
</httpHandlers>
</system.web>
and another question is that in the section why do we remove the asset handler first and then immediately add it again?
<handlers>
<remove name="asset" />
<add name="asset" preCondition="integratedMode" verb="GET,HEAD" path="asset.axd" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc" />
</handlers>
.axd files are HTTP handler files and Telerik probably use them for managing their scripts and assets such as images and stylesheets for their skins.
This handler has to be registered in the web.config so it's executed when the browser requests this file and to ensure it's directed to the approperate HTTP handler. Telerik controls behind the scenes can then safely assume the assets are available.
If you view the generate html source of your application you'll probably see references to asset.axd?blah==3dfijefi if you view the contents of this file you'll see exactly what's going on (although probably minified).
As for why they suggest removing and adding again I suspect it's to stop parent web.config files that may reference older versions etc... ? Just a safety net really.

Why does my WebForms report viewer not display icon resources?

I am trying to integrate the SSRS WebForms report viewer into an ASP.NET MVC2 app. The viewer comes up, but none of the javascript is evaluated. It looks like all of the javascript and icon resources come out of calls to the "Reserved.ReportViewerWebControl.axd" pseudo url. My MVC app is ignoring calls to .axd URI's, but I get tons of javascript errors in the page that's hosting the report viewer. Is there something else that I need to do to get the calls to the .axd handler to work? That particular handler is in my web.config and it looks like this:
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
validate="false" />
For what it's worth, our SSRS is SQL2005, but I am using the SQL2008 report viewer. Do I have to use the SQL2005 reportviewer web control?
Thanks,
Matthew
Turns out I didn't set up the .axd HttpHandler in the correct place in the web.config. I had modified the IIS6 section, but not the IIS7 section. Works like a champ now.

Resources