mvc 4 app on a web server without mvc 4 installed - asp.net-mvc

So I just upgraded my website to a MVC 4 site from MVC 3. My Web host does not have MVC 4 installed but was advised that I can just upload the dlls and all will be alright. I was directed to this link which apparently can be applied when installed
http://weblogs.asp.net/scottgu/archive/2011/01/18/running-an-asp-net-mvc-3-app-on-a-web-server-that-doesn-t-have-asp-net-mvc-3-installed.aspx
I did what is instructed on the following link but then I'm getting an error on my ViewExtensions which apparently (after a 2 hour research) is related to my upgrade (eg. http://s77.codeinspot.com/q/2109234) . Anyway this is the error being thrown.
filterContext.Exception.Message :\hostingpath............... error
CS0121: The call is ambiguous between the following methods or
properties:
'Torneyo.Infrastructure.Helpers.ViewExtensions.AccountProfile(System.Web.Mvc.ViewMasterPage)'
and
'Torneyo.Infrastructure.Helpers.ViewExtensions.AccountProfile(System.Web.Mvc.ViewMasterPage)'
Which doesn't make sense as it's the same and it's just coming from my viewextension class. Following is the part which is being called on my masterpage.
//-----------for master pages
static public User AccountProfile(this System.Web.Mvc.ViewMasterPage view)
{
return (Profile)view.ViewBag.AccountProfile;
}
So these were all working perfectly before the upgrade on the webhost. It runs perfectly on my local before and after the upgrade. I'm not really sure what else I need to do.

Please make sure that you have the correct binding redirects in your web.config. Chances are that parts of the app are referencing MVC3 and other parts are referencing MVC4. A binding redirect from MVC3 to MVC4 will "unify" everything to MVC4.
Check out the "upgrade" guide here: http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806

Finally fixed it. So I tried wiping out the DLLs and reinstalled it but it still doesn't work. What I had to do was to remove everything (Files in the wwwroot folder). And then published it again. Everything worked fine after that.

Related

WindowsAuthentication on ASPNET MVC 3 not working (IsAuthenticated always false)

I'm trying to enable Windows authentication (setting windows mode on authentication) on a huge legacy ASPNET MVC 3 Application, but it isn't working and I can't find why; the Request.IsAuthenticated is always false. The app is very huge and has a lot of personalization with its own authentication and authorization system, but it uses the standard mechanisms of ASPNETMVC to override them (OnAuthorize). I've tried with empty controllers without "personalization" but it doesn't work neither.
I don't know how to start to write here all configuration so, I'm expecting for a genius who could point me to what is wrong...
I've tried too on a sampe new ASPNETMVC3 (from VS2010 templates) and it works fine; I would try to set every thing of my app on this one slowly to try to reproduce if I didn't found any solution before.
--- UPDATE ---
I've copied the web.config and global.asax of template project and it's not working yet. I've added the event WindowsAuthentication_OnAuthenticate on both projects and only enters on the demo project. I can't undersand how, where or why the ASPNET flow is broken.

Routing not working for MVC application under a Webforms website?

I'm creating a Reporting application in MVC that I want to use in multiple websites. I want to be able to simply create an application in IIS under each of the consuming websites and point them to the same directory where the Reporting application is located.
When I tried doing this in an MVC website it worked fine. However, when I tried adding this application under a Webforms website I got a "403.14 - Forbidden" error because it's trying to use the Static File handler.
How can I correct it to use the right handler to route to the Home controller?
The problem was that the base website's app pool was using the 2.0 clr. Once I realized this I made the necessary web.config adjustments and recompiled the app to run under the 4.0 clr and then everything worked.
I also have a bunch of <location path="." inheritInChildApplications="false"> sections. Not sure if those are necessary now, but I'm leaving them since it works and the sub app doesn't need to inherit anything from the base website.
This post (Expression of type 'System.Web.Mvc.MvcWebRazorHostFactory' cannot be used for return type 'System.Web.WebPages.Razor.WebRazorHostFactory') also helped me in trying to get the web.config stuff sorted out while converting from 2.0 to 4.0. That was kind of a pain because there were several errors I had to work through, but I think I mostly just had to remove some sections of the web.config that are no longer necessary (because they're now included in the machine config).

Could not load file or assembly 'DotNetOpenAuth.Core'

I'm trying to implement OAuth in my existing MVC4 website. I had everything working in a test site, and everything was working fine on this particular site. I'm presently getting this error , but my web.config looks like this: . I tried this fix, I've tried GACing the components, I've tried uninstalling and re-installing the NuGet packages, I've tried clearing out the ASP.NET temp files, I honestly don't know what else to try... except maybe put my fist through my monitor.
Does anyone have any ideas? Thanks.
BTW, I solved the problem. It was because the project was upgraded from MVC 3, and I had the MVC 4 assembly in the list. Once I rebuilt the web.config from a new MVC4 project , the bindings stopped getting their wires crossed and the app started working again.
If you run into the same problem and want more details, reply here and I'll post them.

404 Error when moving ASP.NET MVC app from IIS6 to IIS7

I just got a new development box and am having issues getting my MVC project up and running. My old box had Server 2003 and IIS6. I was able to get my MVC apps working on this box after setting up the wild card mapping as mentioned here. My new box is running Vista Business and IIS7. When I copied my app over and tried to run it, I get an 'http 404 The resource cannot be found.' error. However, if I create a new MVC app and run that, everything works fine. I also copied the Nerd Dinner app over from my old box and that works fine as well.
I've verified that the app is running in Integrated Mode and have compared the web.config files of the working and non-working apps but see nothing that is different other than application specific appsettings. I have tried to run the app in Classic Mode with the wild card mapping set, but that does not work either. I have also tried running the app using Cassini, but got the same results.
I have posted the answer on my blog, check it out at
http://nkitdugar.blogspot.com/2011/02/special-care-while-migrating-mvc.html
I had a MVC based application that was earlier hosted on IIS 6. Now IIS 6 doesn't support extensionless URL routes by default, so we need to add some extension to the controller name in the default route defined like {ControllerName}.aspx{Action method}{Id} in IIS6. Also we if we wanted to go for some other extensions like .mvc etc. then we needed to map it using techniques like wildcard mappngs etc.
Now when we have migrated to IIS7, then extensionless URLs are supported which means URLs can be there which don't have any corresponding physical location.
So when you are migrating your MVC application to IIS7 then make sure the default route define in Globla.asax don't have any extension defined with controller like {controller}.aspx\{action method}\{Id} and change it to \clean URL route {Controller}\{Action Method}\{ID(optional)}.
Second thing you should keep in mind that the pipeline mode of AppPool of the website should be set to Integrated from classic.
That's all now your website is ready to be hosted on IIS7.
OK, I figured out the problem. The App in question is a port of a Web Forms app over to MVC as a proof-of-concept project. As such, when the project was first created, we just added a .MVC to the end of the project name to make it {project name}.MVC. This, not surprisingly now that I know what's going on, caused a problem with the default routing definitions. I changed the name to use an underscore instead of a period and everything works now. I'm assuming that it worked fine while running under IIS6 since it was setup using a wild card mapping and therefore there was no .MVC extension to confuse it.

Deploy asp.net mvc beta to iis 6 causing 404's

I'm struggling to get around the 404 errors from asp.net mvc beta when deploying on IIS 6. I had this working in one of the previews by mapping .mvc in IIS but this no longer works. I've read Omar's post and several others on the web and tried their solutions but no luck so far.
The home page opens without a problem on IIS 6 but others 404 and the site runs well on IIS 7.
Has anybody deployed asp.net mvc beta to IIS 6 with success? If so, what adjustments did you need to make to the code and/or IIS settings to get it to work?
I found a solution to my problem from Steve Sanderson's blog (Thanks Steve):
Use a wildcard mapping for aspnet_isapi.dll. This tells IIS 6 to process all requests using ASP.NET, so routing is always invoked, and there’s no problem. It’s dead easy to set up:
open IIS manager (run -> inetmgr -> OK)
right-click your app, go to Properties
then Home Directory tab, then click Configuration.
Under Wildcard application maps, click Insert (not Add, which is
confusingly just above)
then enter
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll for
“Executable”, and uncheck Verify that file exists.
I can't seem to write comments yet. So I'll write a new answer.
There are a few similar questions going around on stackoverflow.
I'm using MVC 3. I know the question was MVC 2 related. But since this is the first stackoverflow post I bumped in to, I think it's worth mentioning that:
when you use MVC 3, you need to add a new extension mapping with the executable of the .NET 4 framework (C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll)
<edit>I just found out that I even don't need to set up the extension mapping. </edit>
It still didn't work for me then :) I still had to 'Allow' ASP.NET v4.0.30319 in the Web Service Extensions section in IIS:
open IIS
click on the server node
open the Web Service Extensions section
select the ASP.NET v4.0....
right click --> Allow
Good to go!
Url rewriting can help you to solve the problem. I've implemented solution allowing to deploy MVC application at any IIS version even when virtual hosting is used.
http://www.codeproject.com/KB/aspnet/iis-aspnet-url-rewriting.aspx

Resources