Call between ambigious RenderActions - asp.net-mvc-2

I recently uploaded my ASP.NET MVC 2 Preview 2/.NET 4 application (Built using VS 2010 Beta 2) to MaximumASP.com's beta websites and when I try to run it I get the following error:
CS0121: The call is ambiguous between the following methods or properties: 'System.Web.Mvc.Html.ChildActionExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string, string)' and 'Microsoft.Web.Mvc.ViewExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string, string)'
This error doesn't show up on my developer machine (Windows 7, VS 2010). Any idea what could be causing this?
UPDATE
I made sure that the .dlls I uploaded with my project are the ones that are working fine with Visual Studio 2010 Beta 2, but I still get the same error when I upload it to my host.
My host is using the newest version of ASP.NET MVC 2 (Beta), but I'm referencing the old Preview .dlls in my web.config and uploading them in the BIN folder, but still nothing.
-

In my case, removing the reference to the old Microsoft.Web.Mvc library from ASP.NET MVC 1 solved the problem.

MVC is NOT supported in VS2010 ... So is this Preview 2 (Although RenderAction is part of MVC2 Beta?)?
http://haacked.com/archive/2009/11/17/asp.net-mvc-2-beta-released.aspx
Unfortunately, because Visual Studio
2010 Beta 2 and ASP.NET MVC 2 Beta
share components which are currently
not in sync, running ASP.NET MVC 2
Beta on VS10 Beta 2 is not supported.

Can you give us the output of typeof(Controller).Assembly.GlobalAssemblyCache, both on your dev machine and on your host? If your controller code is able to run, you can just Response.Write() it, then Response.End(). This will cause your view not to render, so hopefully you can avoid that error.
Edit:
Since your hoster has GACed the MVC binary, you need to compile your site against the same version of the binary that your hoster is using; bin-deployment won't work. If your hoster has installed MVC 2 Beta, you need to compile your site against the MVC 2 Beta binary. Unfortunately this means that you'll have to compile your site with VS2008 + MVC 2 Beta, as VS2010 Beta 2 includes MVC 2 Preview 2, which is an earlier version than what your hoster has deployed.
As a completely unsupported workaround that might make MVC 2 Beta run on VS2010 Beta 2, check this comment on Phil's blog. Note that I mean completely unsupported - it might affect other parts of VS, prevent uninstallation and require reformatting the machine, cause your machine to turn radioactive, etc.
Alternatively, smack your hoster for GAC-deploying Beta binaries and get them to un-GAC it. :) Then you can bin-deploy the particular binary you're compiling against.

Two things I can think of; First, you could make sure not to import one of the namespaces on all of the pages (eg, remove Microsoft.Web.Mvc.ViewExtensions from any <% Import %> statements and from the system.web/pages/namespaces area of the web.config. This unfortunately means that you can't easily reference the extension methods in that assembly however.
An alternative option provided on the MSDN forums would be to write an extension method of your own that just wraps the one you want to call and has a completely different name (eg, BaddieRenderAction()).
Neither option is all that great, but with the second option at least you can get up and running easily and then in the future when MVC 2 is released and your providers GACed assemblies don't cause a problem, you can do a Search and Replace for "BaddieRenderAction" -> "RenderAction" and it's all fixed.

Rather than wrap the Render Action, just explicitly call the extension method as follows:
Microsoft.Web.Mvc.ViewExtensions.RenderAction(Html, ...)

Related

Kentico V8.2 to V9.0 upgrade missing ~/CMSPages/GetResource.ashx

I'm recently going through my first Kentico upgrade on a site that was previously handed to me from somebody else. There were some hinks initially, but I have to say the V8.2 to V9.0 upgrade is gone off with a degree of success. There is one last issue I'm tackling. Initially the issue was with images stored in the database, but I resolved that with setting custom URL extensions. The style sheet we have in the database is returning a 404, so the entire site is without style.
I did some digging, and found the following:
While we were using ~/CMSPages/GetCSS.aspx in V8.2, that appears to have been deprecated/obsolete for some time now. The CSS references in the master page all point to ~/CMSPages/GetCSS.aspx.
In V8.2, I can confirm the presence of ~/CMSPages/GetResource.ashx, but that appears to be missing after the V9.0 upgrade. I installed a blank template site as well to confirm, and it's not there either. I verified I am using the latest upgrade package. I had already hit an issue with the pre-12/15 edition.
The V8.2 ~/CMSPages/GetResource.ashx does not work in a V9.0 as the API for CMS.UIControls no longer contains the ResourceHandler class (which is also used in ~/CMSPages/GetCSS.aspx).
I can confirm in the V8.2 codebase that ~/CMSPages/GetResource.ashx works, returning the specified stylesheet.
TL;DR - Upgrading from V8.2 to V9.0, I appear to be missing ~/CMSPages/GetResource.ashx, and am not sure where it got off to.
Environment Information
Test Server: Windows Server 2008R2 SP1 on IIS 7.5 w/ .NET 4.5.2, MSSQL 2008R2 Database backend
Dev Server: Windows 8.1 with IIS 8.5, VS 2015 and MSSQL 2008R2
Kentico V8.2 Site in Portal Mode
I appreciate any ideas you have.
Thanks!
Most of the .ashx were moved to the CMS.UIControls assembly and adjusted to implement IHttpHandler.
This way the handlers can be used by any application that references the Kentico libraries, specifically the UIControls. This approach has been utilized e.g. in the new MVC support in Kentico 9.
If you need to customize the handlers you can take advantage of the GetFileHandler and AdvancedGetFileHandler abstract classes implementing IHttpHandler.
I was receiving a 404 on GetResource.ashx in v8 when deploying my site. I have my site setup as a web application. My problem was I was only deploying CMSApp using Visual Studio. I needed to also deploy CMSApp_AppCode. https://docs.kentico.com/display/K81/Publishing+web+application+projects+from+Visual+Studio
when I upgraded to v9 from v8.2 I was getting a 500 Error on GetResource.ashx. After my upgrade I just re-deployed. I don't know what the issue was, but getting the errors, I cleared out all the files on the Azure server then deployed. This fixed my error.
Maybe one of these two items will help you.
If I read the release notes correctly, they moved the files to the UIControls library and you can still utilize the old references without issue. I've upgraded my website from 8.0.48 to 9.0.1 and 9.0.4 and had no issues. In fact, I still use the /CMSPages/GetResource.ashx?scriptfile=/path/to/file.js I believe the change was specifically to accommodate the MVC model.

ASP.NET MVC 2 site issues when updated IIS7 to .NET 4.5

I have a web app running ASP.NET MVC 2 along with other sites (using ASP.NET MVC 4), updated IIS7 to use .NET 4.5 and my MVC2 app stop working properly:
Issue: (blocker)
There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined
the solution:
comment out a section of web.config, based on http://forums.asp.net/p/1571308/3939106.aspx:
Issue: (blocker)
Login stop working, the solution add this line <machineKey validation="SHA1"/> to web.config, based on Login fails after upgrade to ASP.net 4.0 from 3.5:
Issue:
One of the views is giving a Compilation Error:
CS0104: 'ContainerType' is an ambiguous reference between
'System.Web.DynamicData.ContainerType' and
'MVFleet2.Core.ContainerType'
on this line :
<%foreach (var specs in (List<ContainerType>)ViewData["ContainerTypes"])
This error never happened before the update, I know the obvious solution is to use the full name for the cast, but I'm looking for a solution so i can force the web app to run in the context of .NET 3.5 and bypass this issues, so i don't have to deal with this and probably more issues in the future... is this possible?
If you want to use the older version of the framework (.net 3.5), you need to change the Application Pool in IIS to run as .Net 2.0.
You should fully qualify the ContainerType type definition to MVFleet2.Core.ContainerType.ContainerType.

NUnit Test framework for ASP MVC 4

How can I create nunit testing project in asp.net mvc 4? I have followed the steps in the below link
http://www.geoffhudik.com/tech/2012/4/21/aspnet-mvc-4-nunit-template.html
But, I can't find the NUnit test option when creating MVC 4 application. But this option will be shown for MVC 3 application.
Please anyone let me know the solution for MVC 4.
Things are much simpler now:
Inside VS2012, go to Tools - Extensions and Updates - Online -
Visual Studio Gallery.
Search for NUnit.
Select ASP.NET MVC NUnit.
Click Download.
When it has downloaded, you will need to restart Visual Studio.
Voila, you have everything you were after from this page.
(I'm not sure, but I think this only works for Standard Edition and higher. Please correct me, if this works for Express Edition.)

MVC3 could not be installed in xp

Friends Initially there was problem in the re installation of VS 2010 in my computer with Xp.
But i was able to install recently and every thing goes fine. I was able to use MVC 2 and other features. But when i tried to install MVC 3 i could not get success.THe installation process Roll back giving the message of FATAL ERROR DURING INSTALLATION.
Then i check in the error and found that Microsoft ASP.NET webpages 1.0 was missing in my computer.Is that the problem for installing MVC 3? or other .
I have attached the screen shot of error. I will be thankful for the solution.
Sorry, i couldn't upload clear picture.But Error shown was as follows:
Returning IDOK, InstallMessage_error[This product Requires Microsoft Asp.net web Pages 1.0. Please install the missing component, then try to install this product again.]
strong text
Using the Web Platform Installer will probably be the easiest way for you to solve your dependency installation problems. Using the installer will give you the ability to select and download/install a variety of products. For instance take a look at the follow screen shot:
Under the Products tab, you have the ability to select MVC3, ASP.NET web pages, MVC3 Updates, etc. Since some products depend upon others the Web Platform Installer will also manage these dependencies for you when installing your selected items.
Good luck, and hope this helps you some.

Check if .NET 2.0 is properly installed

Is there anyway i can check if .NET 2.0 is installed without any errors?
The answer here led me seriously astray... i found microsoft's own documentation: .NET Framework 2.0 Redistributable Package Reference: Detecting Installed .NET Framework 2.0
This documentation states:
The Setup.exe bootstrapper should use the following registry key to detect the .NET Framework version 2.0.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727
It then verifies the existence of the entry value:
Install (DWORD value = 1)
Note The same registry key will be checked for all versions of Dotnetfx.exe regardless of language. Therefore, if you want to display dialogs in a specific language you should use the corresponding version of Dotnetfx.exe. You do not need to make any changes to the settings.ini file when deciding which version of Dotnetfx.exe to use.
works like a charm... i realize this question and answer is 2 years old or more... but i got here from a search engine, and this is here for the next person who does the same... hope this helps -ck
This blog post describes two options for checking for a .NET installation, as well as retrieving versioning information.
The second option (using CorBindToRuntime) will fail if the .NET installation cannot be loaded. This might help you determine if there are any errors in the install - or at least whether the framework loads properly.
If you're using ClickOnce as your publishing method, you can click on the "Prerequisites" button in the "Publish" tab of the project's properties and check the box for ".Net Framework 2.0". This will make sure that framework is installed before the program installs, and can fetch and install the framework if necessary, too.
In regular VS Setup Projects, right-click on the setup project, chose View->Launch Conditions and add it as a condition. Visual Studio should have added one for you that matches the target platform of the project.