Configuration Setup for Asp.net mvc 3 application - asp.net-mvc

i have an asp.net mvc 3 application that i want to deploy but i want to somehow automate the deployment process of the application. For example if i upload code to http://www.domain.com. when site is run for the first time it should check if database is setup if not it should run the sql server scripts from the scripts folder to user's specified server for his specified database. Then there are some settings that it should accept from the user and store in web.config like smtp, Official Email, phone etc. These are settings that are required only once in the lifetime of the application. Then there are settings that application should prompt at the end of the financial year.
what is best way (even a way would be highly appreciable) of doing this kind of stuff in asp.net mvc.

Rather than outlining the whole process here, I will instruct you to check the Orchard setup, it does something similar, you might want to check out how they do it:
http://orchardproject.net/

Related

ASP.NET MVC - Creating SAAS framework

I currently have a ASP.NET MVC 2 web application and would like to enhance the architecture to support a SAAS model. I plan on eventually building a number of web applications so would like to design the system accordingly.
The goal would be that when a client would hit the following url clientxyz.domain.com they would see an image of all their subscribed applications. This would essentially be a web page with a bunch of application icons. Once a client would click on a icon it would navigate to that actual web app at the following example url clientxyz.domain.com/application_name.
We currently use GoDaddy to host our domain and plan on using a Cloud based iLand server to host our application. We only plan on a few new clients a year due to the nature of our software.
I have a number of questions:
Is it possible to programmatically create subdomains on the fly using a .Net api. I'm pretty sure GoDaddy does not let you do it. So is there another provider that would let me create subdomains via C#. This may be the wrong approach and may not even need to physically create client subdomains. Instead I may be able to accomplish this using url rewriting in IIS/MVC?? If I use rewriting, it would have to satisfy the url requirements mentioned above. Any suggestions/links/examples?
Should I create a separate IIS website for each tenant/client? Or should I use URL rewriting and simply have a single website / application pool? Looks like you can programmatically spin up IIS websites (example: http://www.eggheadcafe.com/tutorials/csharp/d4bba585-b517-4834-8476-ff05b085d86e/iis--create-app-pools-virtual-directories-and-web-sites-c-net.aspx)
Since we are using a Virtual Server on iLand do I simply have to point GoDaddy to the nameserver at iLand.
I would like to automate the entire new client process if possible. To accomplish this, I would have to created the database (probably going to have single db per tenant), populate the global client/tenant table, create admin user account and subscription details in newly created database and create subdomain depending on approach. Am I missing anything?
thanks in advance.

bulk create user accounts to asp.net mvc3 membership tables in production environment

In dev environment I am using the ASP.NET configuration tool in Visual Studio to create a few users for testing. As I movel closer to QA and Production, I'm wondering what is the best way for me to automate the creation of a large amount (1000's) of users after application deployment.
I have a csv with all the usernames and passwords, roles etc. and I wan't to avail of the encryption and password salting security that is built in. I do not want to manually "Register" all these users.
I'm just not sure if this is something I can do (or instruct a db admin to perform for me).
Does anyone know of a way to achieve this?
Any assistance would be greatly appreciated.
Regards
The simplest solution would be to set up a "CSV Upload" form. The CSV would be processed by an MVC action calling Membership.CreateUser in a loop.
Probably, the performance of this will be good enough.
There's a few ways that I know of approaching a batch processing problem on an ASP.NET site.
Because of the wonky way an ASP.NET site's application pool can get recycled, batch processing is usually done on an external process.
Windows service
One way is a separate windows service, which gets the new excel and pumps that data in, and has a timer which keeps going around. I've seen this used often, and it is quite a pain, because it takes extra work to make it easily deployable.
Update ASP.Net membership from windows service
CacheItem
Second way is to use CacheItems and their expiration timers to do batch processing, what you do is you define a cache object with a long timer, and when that expires and the Removed-callback gets called, you do your database work. This is good because it deploys with your ASP.NET site, and you have your code in one logical place.
https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/
Workflow Foundation
Third way, is to make a workflow foundation service. That service gets a call from your ASP.NET site, which instantiates a WF service, that does some db work with your excel file, and then it goes into a while-loop with a delay of a month in it. This is good, because it is not tied to the lifespan of your ASP.NET application pool - you get more control, and this logic can be separated into a different IIS hosted WCF service.
http://msdn.microsoft.com/en-us/library/dd489452.aspx
Integrating with data is always a pain though, remember that the solution that gives you the least work and least chance of failure when deploying is the best solution.

Best practice for deploy website

I would like to know the best practice to deploy a website.
What I usually do is to minify all the javascript and css file, clean the html code from comments and publish my solution with Visual Studio.
There are other best way to put online a lower weigth website?
Try to execute Production deployments when there are few if any users online, such as at night or weekends. Notify users that there will be a scheduled outage.
When deploying to the production environment, you can create a "App_Offline.htm" file and place it in the root of the ASP.NET website. ASP.NET recognises this file has a special meaning - all dynamic page requests are shown this page instead of the page requested by the user. Typically this page displays a friendly message such as "The server is down for routine maintenance. Please try again in 30 minutes."
Another tip to make deployments less painful is to keep your web.config as similar as possible between your various environments such as Development, Test and Production. For the things that really have to change on the different environments, such as connection strings, you can extract these into their own connectionStrings.config file, by setting in web.config.
For database deployments, there are some great third party tools (such as Teratrax Database Compare for SQL Server) which allow you to compare the schema and/or data between 2 databases and produce a SQL script that will migrate the target database to the schema of the other database. Whether this works for you will depend on your exact development practices. If you cannot use such tools, you could script every database change, then replay those scripts when deploying to a different environment.
And of course you should ideally have a Test environment which is exactly like Production and enables do all your acceptance testing and to ensure your release is stable and your deployment is going to work before you do the real thing.

What db structure fits for site builder

I need to build web application that will do:
build web pages.
build template for page.
add module(by module I mean ContacUs form, Search, Billing System...). Each module can be constructed by submodules or diveded to submodules
build module(add form, textbox, button...) and that all entered data by user could be saved in db
Can you advise me a DB structure that will contain it all
I looked some cms db, but it's NOT this.
Please, don't ask why I mess with it. I just need to build it.
I suggest you DotnetNuke.
DotNetNuke is the leading Web Content Management Platform for Microsoft ASP.NET, powering over 600,000 production web sites worldwide. The flexible DotNetNuke platform functions as either a Web CMS or a web application development framework. Depending on your role within your organization, DotNetNuke provides powerful benefits to support your Web initiatives.
http://www.dotnetnuke.com/tabid/125/Default.aspx

How to create roles and superuser in an ASP.NET MVC application in a secure way

This could be considered a duplicate question, as a similar one has already been asked, but I don't like any of the answers, and security was not addressed.
When deploying an ASP.NET MVC app, what's the right way to create roles and a superuser without risks?
Two ways come to my mind: using Application_Start or a custom action (better if with a non-obvious name and not linked).
Anyway, what about with first user's password?
I've seen tons of web apps that happily let the first person to access them to be the superuser; when you put such an app online, you can only pray to be the first to connect.
What is the most secure way to set password?
Hardcode it in the application?
Have it randomly generated and then mailed somewhere?
Have it randomly generated and then saved somewhere on filesystem?
Have it taken from a file on filesystem?
Something better that I couldn't figure out?
The best solution to this I have seen is to allow for the creation of a superuser via some installation bits then require the user delete or disable the installation bits for the application to run. Subtext works this way, as did Wordpress (at least the last time I installed it, which might have been back in the 90s).
I use the ASP.NET membership provider and a SQL database.
Upon deploy, I have a script I run that creates my users.
It does mean my site is not "ready for business" until I run the script but I am okay with that.
Kindness,
Dan
Assuming the admin of the application doesn't want to run upload a pre-configured database you could configure an installation password in your web.config which must be set before it is uploaded. Then in your installation pages prompt for this password and the admin credentials. Obviously your installation pages would check for a blank installation password and refuse to proceed.
You could then add an HTTP handler which checks if the application has gone through the installation procedure, refusing to serve any pages other than the ones related to installation until the install is complete.

Resources