Add a sitemap provider at runtime in asp.net (MVC framework) - asp.net

I'm building a regionalized site each region has it own sitemap and own content.
The regions can be added at runtime.
Is there any way to add a sitemap provider at runtime?
I need multiple site map providers at once so that I can leverage the mvcsitemap without to many changes.

You can create your custom site map provider in order to take information from database or from another file than web.sitemap.
Example of database sitemap: http://msdn.microsoft.com/en-us/magazine/cc163657.aspx

There is an MVC sitemap provider available at: http://mvcsitemap.codeplex.com/
I'm using it for a project right now. It has caching functionality built into the code so your overhead shouldn't be too bad. Even in debug mode running the sitemap for every request takes < 100 ms so I wouldn't worry about performance.
Your performance concerns are a little yagni too. "Could be quite resource consuming". You don't know so your just prematurely optimizing.

Related

MVC mobile site as subdomain in Webforms site

I have an existing webforms project, and I want to add my new MVC4 (mobile-focussed) site to it, as a subdomain. I also want it to be able to access the session variables from the webforms site. The idea is that the user logs in on the webforms site, sets a session variable and gets redirected to the mobile site (on the subdomain).
Initially I have added my MVC site to the webforms site, by making changes to the web.config, global.asax (for routing etc.), Controllers, Views and other folders at root level. This allows me to access the session variables. However because the webforms site is well-established (old) there are implications to changing the web.config (least of all re-testing). Hence the need for a subdomain.
Is it as easy as dropping my MVC site's folder into the Webforms root, so it has its own web.config, and changing the global.asax to route to it (and then creating a subdomain)? Will I still be able to access the session variables in the subdomain?
You can create a new project for the MVC mobile, configure the domain binding in IIS in something like that m.mydomain.com.
In the web.config of the two you define the same main domain:
<httpCookies domain=".mydomain.com"/>
Here start the difficoult task, you need to play attention to share the same machineKey in the two projects and probably you need to add an HttpModule depending on the selected session scenario.
Take a look on this article that can help you on some guidance.
To share the session, I implemented this from Microsoft. It is a HttpModule.
http://support.microsoft.com/kb/2527105
There was some additional work to do - I felt this article assumes you know a little about IIS. For example I had to manually add the module using IIS Manager.
I managed to get it to work in IIS7 by manually adding the Module using IIS Manager.
(Open IIS Manager -> select the application -> click modules (top right) -> add the SharedSessionModule by clicking 'Add managed module'.
Name: SharedSessionModule
Type: <namespace>.SharedSessionModule
(a dialog box said it could not find the assembly but at runtime it was fine)
Then Restart IIS.
The problem I then had was "session state is not available in this context" when serving up non-page items like images, .pdfs etc. Before I solved this, I have been asked to use my initial method (side-by-side) so I have not found how to change this BUT there are many suggestions on SO and other sites.

Does Orchard support some form of config transforms?

What is "the Orchard way" to define environment-specific configurations and/or configuration transforms? Is it possible to use regular Web.config transforms like in any other ASP.NET web app, or does Orchard have it's own engine for this?
(I've not been able to find any useful information on this topic in either the official docs or out in the wild.)
It's perfectly possible to store that information in web.config, as in any other ASP.NET application. In lots of cases it's the only way to go (eg. environment-specific IIS settings and so on).
You may also store custom settings in Orchard database, by writing your custom settings part and attaching it to "Site" content type. It's the preferred way to go if you have some data to store, that does not have to be kept inside web.config file (alternative to creating a custom config section).

New ASP.NET website using DotNetNuke

Currently using DNN 5.2.x and we are using only 1 portal on the site. We need to make a mobile version of the portal and eliminate most of the extra DNN stuff as info will be just displayed. So what we decided to do was create seperate ASP.NET Web Forms website and utilize the DNN providers (membership, roles, etc) to do the logging in. However we are currently having issues. The one in particular is ("unknown exception trying to write to log"). We've moved most of the DNN Global.asax (i.e. SimpleContainer instructions) file to the new website and added the necessary web.config sections and references however we get this error when a user logs in. We did copy over the same web.config machine key to the new website. The connection strings are also there (app settings and connection string sections and is named SiteSqlServer).
So my question is, has anyone created a new website around DNN without using DNN except for the membership? i.e. no modules, no skins, etc. Just validate user and get roles.
If you have what needs to be done to get DNN 5.2.x (or later) to log a user in and return the roles, could you post your steps?
The default DNN login is based on ASP.NET membership. If all you really want is the login feature, it will be MUCH MUCH easier to simply use the ASP.NET membership directly than try to rip it out of DNN.
What you are trying is not impossible, but certainly will require substantial patience with trial and error.
For only validation users and getting roles you could write your own simple providers that utilize dnn special tables in the databse like (Users, Roles, UserRoles, Profile etc). The table User is associated with the aspnet_Membership and aspnet_Users standard tables via the Username field.
There are many options which are open for you.
If you really don't want to digg into complecations of how to integrate the dnn membership and role provider will work, you can check dnn single sign on
Another option is to have your webforms application as a subfolder in your dnn website. that way you don't have to do much effort and you will have all the good things ready to get started. even you can directly convert your skin to master page and reuse almost all the css and image related suff
In addition to above, I also suggest another smart way to do this. Since you are considering a mobile site, why don't you try and detect the browser using Request.Browser and create a separate skin for dnn that is of smaller size. We can easily switch skins dynamically for service requests.
I hope this will help. If you have more questions regarding this, I will be happy to help. Just drop me and email and I will try to help you get as close as possible to get you going.
Good Luck
This is the route we took. We basically implemented DNN in the mobile version of the website. Except we only utilized the User Membership features of DNN. To do this we had to use all the same core DNN dll's and also include all the "bootup" features in the global.asax file. We also had to on every request inject a UserInfo object into the session context. I forget the key name for the UserInfo oject used but it is used by DNN and must be set in a DNN handler that we did not incorporate. Other than that it works perfectly. We have the ability to get all the roles a user is in and etc.

About using ASP.NET security and Membership in web applications

I have 3 questions about using ASP.NET security and Membership in web applications
Do people outside localhost have any means of accessing the ASP.NET security control panel?
What is the best way to edit security? Is it by opening the website through VS2010 and editing security, or there is another way or some control panel I can use?
I can't edit security while the folder is in wwwroot, so I have to cut it into desktop, edit its security the put it back in wwwroot folder. I don't think this is an acceptable way at all, any better ideas?
The Web Site Administration Tool (WSAT) is the default means to manage a ASP.NET site out of the box. If you want a deployable solution that can be integrated into your website you should look at the MyWSAT project on CodePlex. It provides all the features of WSAT.
1: No you cannot access the WSAT tool outside of localhost and it has to be used in conjunction with VS. (Note: I have seen people trying that but somehow it isn't easy.
2: You can use modules already created by others as one mentioned by Zack. Similar one is here. Or you can use Membership/Roles API to write your own pages do this work.
3: Not sure what is going on with your wwwroot issue. May be it could be some permission issue. Are you getting any error?

How could I use ASP.NET MVC framework in conjunction with my CMS software?

I have been reading on MVC and I created some db-driven pet projects with it and I am very pleased with the shift from WebForms.
However, I have a bit of a limitation that holds me back with WebForms and I was wondering if you could help me with it.
I work for a Web CMS company as a Consultant, therefore all websites (public sites, intranets, extranets, you name it) are based on the CMS software from my company (which should remain nameless).
One of the features that the sales guys like to pitch about our software is its "friendly" urls. Baiscally all data is stored and structured within the CMS like a file system. Then when you point your browser to http://mywebsite.com/about the CMS will return the contents from the item stored under the root with the name "about".
Each item also has a (interchangeable) template registration which is the physical location of the file that is going to display the contents of it (an .aspx page). Just like the "Views" on MVC.
To handle the friendly URLs I have to add a HTTP Handler as follows:
<add verb="*" path="*"
type="Cms.ASPDelivery.HttpRequestHandlerFactory, CmsDelivery" />
That will take care of the friendly URLs and will do the mapping between contents and views.
In an architectural way you could see that just like MVC. The data is stored in the CMS, the presentation is independent of the data, and the handler will be the Controller.
But when it comes down to coding in itself, it is the same old Webforms spagetti.
So, my question is: Do you see any way that I could use both MVC and my CMS' Http Handler?
It depends on the concrete Implementation of the HttpHandler but in most cases it is possible. You have to add the MVC UrlRoutingModule and setup the MVC. I use MVC in a CMS environment with friendly url-s. The CMS is called EPiServer and from what you described it has pretty much the same functionality. I use ASP.NET MVC for the template pages. The path to the physical pages is actually handled by controllers' actions. It works fine and with some tweaking I can say that it is a lot better than WebFroms especially if you develop custom web applications.

Resources