I'm trying to implement MvcSiteMapProvider with my new MVC4 website, but I've run into something that I can't seem to fix.
I setup authorization with Active Directory (no role provider currently), and everything was working as it should. When you try to get to any page other than the login page, you're redirected to the login page. The Account controller's action methods have the [allowAnonymous] attribute to allow unauthenticated users to access them so that they can login.
For some unknown reason, adding MvcSiteMapProvider to the project stops this from working and now unauthenticated users can get to any page. The Menu that MvcSiteMapProvider creates works correctly and only authenticated users can see it, but if the unauthenticated user types in a direct link they aren't redirected to the login page as they used to be.
I've removed MvcSiteMapProvider from the project and authentication started to work correctly again.
I believe this has something to do with MvcSiteMapProvider overridding the authorizeAttribute filter in some way, but I can't figure out where/how.
I can put [Authorize] on top of the controller and the redirect works with MvcSiteMapProvider, but that's against the whole reason for using MVC4.
//this is supposed to set authorize for the entire app
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new System.Web.Mvc.AuthorizeAttribute());
}
I have a feeling this issue is coming from MvcSiteMapProvider/External/AuthorizeAttributeBuilder.cs, but I'm not experienced enough to figure this out.
UPDATE:
Turns out that I had just setup my global filters incorrectly. For some reason that RegisterGlobalFilters method was in my global.asax file, so my FilterConfig.cs file didn't have the line:
filters.Add(new System.Web.Mvc.AuthorizeAttribute());
I removed the method from my global.asax file then updated the FilterConfig.cs file with the above filter and everything is now working as expected. Not sure how I got into this situation, but I'm glad I figured it out.
Someone on the mvcSiteMapProvider GitHub project had mentioned that he had MVC4 and mvcSiteMapProvider working seamlessly, so I created a new MVC4 app and added the mvcSiteMapProvider before making any changes and then added the authorize global filter. Everything worked as expected, so I compared projects and found where I had gone wrong. Hopefully this info helps someone, but I doubt it as it's a pretty unique case.
Turns out that I had just setup my global filters incorrectly. For some reason that RegisterGlobalFilters method was in my global.asax file, so my FilterConfig.cs file didn't have the line:
filters.Add(new System.Web.Mvc.AuthorizeAttribute());
I removed the method from my global.asax file then updated the FilterConfig.cs file with the above filter and everything is now working as expected. Not sure how I got into this situation, but I'm glad I figured it out.
Someone on the mvcSiteMapProvider GitHub project had mentioned that he had MVC4 and mvcSiteMapProvider working seamlessly, so I created a new MVC4 app and added the mvcSiteMapProvider before making any changes and then added the authorize global filter. Everything worked as expected, so I compared projects and found where I had gone wrong. Hopefully this info helps someone, but I doubt it as it's a pretty unique case.
Related
Scenario:
I have a website (CATALOG.COM), without any validation request, and without source code.
Now I need to set a validation to access.
Possibility Solution
If I create another site with validation (START_WEB.Com), and after I redirect on CATALOG.COM, can be a good solution ?
For example:
[Authorize]
public ActionResult Run_Old_WebSite()
{
return Redirect("www.Catalog.com");
}
Any suggestions?
p.s. I work with Asp.net, Mvc and Bootstrap
without the source code availability , You cannot validate the page.
Below is the alternate solution for this:
When any one hit the CATALOG.COM apply the 301 redirection rule to it and return it to the new site url like: START_WEB.Com?returnUrl=CATALOG.COM
Then in the new site add some validation login page, authenticate it and then redirect it to the old url: CATALOG.COM?validated=true
In this way you can achieve this, Here you can track the users also who are visiting to the old url site.
Assuming you have access to the published files, I would copy them to my local machine, decompile the site specific assemblies using something like Jetbrains dotPeek (it's free) and re-create a new solution in Visual Studio with the decompiled sources. Depending on site size/complexity this may take a bit of time but you would at least be able to make improvements to the code,build and deploy.
I am using umbraco 7.1.3.
My requirement is to create another sub-domain in main site dynamically as per user request.For example I have implemented umbraco cms for my site "ww.xyz.com" & I am updating content through umbraco login. Now I want to create sub-domains for different clients as per their request... like : "www.xyz.com/client1", "www.xyz.com/client2" and so on...
Now all sub-domain site should have it's own umbraco framework, so client-site (sub-domain owner) can login and update their information respectively.
To achieve this requirement I implemented following steps...
First I register a umbraco website in IIS and configure it, and that worked properly.
Then I register another umbraco website in IIS and configured it, and that also worked properly.
Now to implement sub-domain logic...
I simply copied 2nd website's folder in to first website folder. Then convert that folder to application through IIS.
As per my expectation this should work, As I have already done the same in asp.net and it worked.
But with umbraco I am facing issue like "Invalid key value".
I think the issue is related to some umbraco configuration, but I am not able to figure it out.
Thanks & Regards
A bit of an open door, but since I don't see it mentioned in any of the comments and it's a bit hidden away in Umbraco 8. Have you tried setting the urls in the Cultures and Hostnames section?
Note: you get to this by going to "Content", in the content tree right click on your homepage and now you get several extra options which are normally hidden away with also the very useful Hostname and Cultures option which allows you to support multiple urls.
I have implemented my own VirtualPathProvider for loading 'embedded' views.
This works very well when running from Visual Studio, but I get the 'The view not found' message when running on IIS6.
Is there anything missing in web.config, or could there be any other problem?
I have added some logging and it seems that even though I register the Custom VirtualPathProvider in Application_Start, the System.Web.Hosting.MapPathBasedVirtualPathProvider is still used.
For the combination Custom VPP + IIS6 + Precompiled site, we need to add the VPP from AppInitailize();
public static class AppStart
{
public static void
{
// code to be executed automatically by the framework
}
}
See also:
http://sunali.com/2008/01/09/virtualpathprovider-in-precompiled-web-sites/
Is yours not used at all? VirtualPathProviders operate in a stack so, in your VirtualPathProvider, you should notice that the base class member "Previous" is actually the instance of "MapPathBasedVirtualPathProvider".
If you:
Attach your debugger to IIS
Make a change in your web.config, then change it back, then save (to trigger an recycle) - while still attached!
Place a breakpoint in your VPP in FileExists
Hit a page
Does your VPP get hit? If so, it may be an issue that after the first request, MVCs ViewEngine caching is preventing your VPP from getting hit for additional requests...
I have a ASP.NET MVC app and when I run it, it loads my Index action on my HomeController
by default ok.
But when I put in this URl I get 404 - Not Found error
http://localhost/MyGoogleApp/Home/Index
This is the same for any action I put in in Home Controller.
Something fundamentally wrong, any ideas?
Malcolm
You probably have a configuration problem with URL mapping in IIS itself.
I haven't worked much with IIS7, but I think this is what you should check:
Managed pipeline mode should be 'Integrated'.
web.config should include system.webServer with all standard stuff new MVC project puts there (I can't check what exactly right now).
I followed the guidance in the Professional Asp.net 1.0 Wrox book for adding the MVC references to an exisiting web application and it works well except for the scaffolding options. When i right click a controller i do not get the scaffold view options that you get in a new asp.net mvc app. I am sure there is a .csproj hack that is needed to get the scaffold options but i can't find any references anywhere. Has anyone else run into this and found a solution?
Well google to the rescue. I found an answer at the following blog: http://wildermuth.com/Tag/ASP.NET+MVC
You need to edit the .csproj file and add to ProjectTypeGuids {603c0e0b-db56-11dc-be95-000d561079b0}. Order seems to matter. Originally i added to the end of the guid list and the project would not load and threw an unsupported error. I created an empty mvc site and looked at the guids and the guid above was listed 1st. So i added it to the beginning and everything worked fine.
Have you looked at how you register the data context in you Global.asax file?
This link may have more details that can help:
http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.metamodel.registercontext.aspx
and this:
http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.metamodel.aspx