Using Windows Azure and ASP.NET MVC with Membership - asp.net-mvc-3

I had an ASP.NET WebForms application. I have been migrating it to use ASP.NET MVC. In the process, I had to strip out my membership code and use a newer implementation. Currently, I am successfully using the SQL Table Profile provider with Windows Azure: http://code.msdn.microsoft.com/Using-the-SQL-Table-4c220996/view/SourceCode#content
My challenge is, what is the equivalent for membership? Considering the SqlMembershipProvider will not work with ASP.NET MVC, I'm not sure what to use now. I need to authenticate my users. Can someone please tell me what "DefaultMembershipProvider" I can use with my tables that are hosted on SQL Azure?
Thank you!S

You would need to use SQL Azure with your webrole to get it working. Sql Azure database has the Asp.net membership/role etc. tables, then Membership and Role provider will work normally without further changes to the Provider. And you sure can use SQLMembershipProvider with MVC3 ASP.NET Web Role and SQL Azure on Windows Azure. You may find articles on internet on how to use it all together:
http://romikoderbynew.com/2011/02/02/using-autofac-mvc3-sqlmembershipprovider-and-entity-framework-in-windows-azure-and-sql-azure/
Also you sure can create your own if wish to as described in this discussion:
ASP.NET MVC3 Custom Membership Provider - The membership provider name specified is invalid

Related

How do I use old membership system of ASP.NET 2 instead of ASP.NET Identity in ASP.NET 4.5?

I am working on a web application and I need to use a legacy membership system. Can you help me to know how should I have that database and how to implement that membership system in my web application that uses .Net 4.5?
let me explain it, you know nowadays we are using ASP.NET Identity but if you remember in past we were using ASP.NET Membership in .Net 2, can you remember old membership and authentication system? now i want to use that system instead of ASP.NET Identity. with old tables and structure.
Here is the history -
Membership Provider
Universal Providers
Simple Membership
ASP.NET Identity (Current version is 2)
ASP.NET Universal Providers is the last version of old ASP.Net Membership Provider. It uses Entity Framework Code First under the hood.
If you really have to use ASP.Net 2.0 Membership Provider, you need to use aspnet_regsql.exe to generate schema and store procedures. It is pain in the neck.
Here is the step-by-step instruction at 4guysfromrolla - Examining ASP.NET's Membership, Roles, and Profile

What is the difference between the regular Oracle ADO Provider and the Oracle Web ASP Provider?

I am migrating off of Microsoft's OracleConnection class for a asp.net-mvc website given that its being deprecated. I see on the oracle site, there are 2 different options, one is the Oracle ADO Provider for .Net 4 and the other is Oracle ADO ASP Provider for .Net 4. I am trying to figure out the difference because the code that I use to access Oracle in my site is not web specific (its sitting in a different project to the main MVC project and I plan on using this library in desktop apps as well).
Can someone explain the difference between these two libraries and advise on which one I should use for my situation?
The Oracle website can be a problem! :)
The ADO provider is the standard data access code for Oracle from .NET:
Oracle Data Provider for .NET (ODP.NET) features optimized ADO.NET
data access to the Oracle database. ODP.NET allows developers to take
advantage of advanced Oracle database functionality, including
Real Application Clusters
XML DB
The Oracle Providers for ASP.NET you mention, is a specific release for helping with things like ASP.NET State Management, Membership and Roles:
ASP.NET provider developers will discover the
Oracle Providers for ASP.NET are easy to learn and use as they share a
common schema and API with existing ASP.NET providers. They integrate
seamlessly with existing ASP.NET services and controls, just like
other ASP.NET providers.
Oracle offers the following providers:
Membership Provider
Role Provider
Site Map Provider
Session State Provider...

ASP.NET Universal Providers & Azure - Users Created Through ASP.NET Configuration Not Working

Describing this in detail is going to be tough but here goes:
Configuration
ASP.NET MVC 3.0 Website Project
Visual Studio 2010 SP1
Windows Azure Deployment including, Compute, Storage and SQL
SQL Azure has two sets of DB's; Development & Production
Problem
Using the ASP.NET Universal Providers I've setup a Development_ApplicationServices DB in my SQL Azure account. I've then gone in to the ASP.NET Configuration Website and created users for Development and assigned them to roles. As there are multiple developers working on this project this works well so we consistently have the same default accounts available to test role related use cases. Development has been running smoothly without any issues with the Providers.
I posted the Application to an Azure Compute Instance today for the 1st time and tried to login. Suddenly, the accounts we've been using, despite pointing at the same database are not working. If I register a new account it works fine while I'm in the Azure environment however, if I run in the development environment and then the account I created on the Azure instance using the default Register function of MVC in the Account Controller isn't accessible though I can see it in the DB if I query directly.
Question
Does the Universal Provider embed something about the Site Context (for lack of a better term) into the hash for UserID or Password?
Is there a best practice for the way I've configured by Dev/Prod environment, as it relates to SQL Azure and Membership Services, that I can use as reference?
Happy to answer questions to make this more clear but I'm pretty stumped at this point and don't know what would be relevant to include since this seems odd, to me at least.
Thanks in advance,
K
I was also getting this exact same behavior. I posted a question on the official Azure forums ( http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/e8944c4d-5e22-4844-82fc-2e6863f0901a ) and was directed to the answer in another post here on stackoverflow I didn't find during my initial searching.
You'll find the answer here:
ASP.NET Membership - login works locally, fails on Azure
To summarize, the hashing type used on Azure is different from that which is now the default for .NET 4.0. You have to explicitely override the default machineKey element and the hashAlgorithmType attribute of the membership element in the Web.config to specify the hashing method to use.
It worked for me!

MVC3 Table Storage and Account Validation examples

Has anyone seen any good examples of how I can use MVC3 and TableStorage with Azure account validation. Everything I look at seems to still be ASP.net or just a very basic example. I am surprised the Windows Azure site doesn't include more MVC examples.
What exactly do you need and what do you mean by "Azure account validation"?
As for Storage - the Microsoft.WindowsAzure.StorageClient.dll is a single assembly with common wrapping types around the Storage API. There is nothing technology specific. You can use storage client in any .NET assembly (well, not in Silverlight directly). But all operations over Windows Azure Storage are performed the same way regardless of whether it is a ASP.NET application, or MVC site, or WPF application, or WinForms application. So you may take the Azure Storage related code in your MVC application and use it as is. You just need an MVC3 Web Role, which is a standard and available project template since Windows Azure SDK 1.5.

Hosting site Asp.net MVC and SQL Server Compact 4

In my ISP, they must hire service SQL Server to host a sql server compact framework?
The fact that MVC requires the host to have some extra service? Or a simple hosting plan already supports asp.net MVC?
You can bin-deploy SQL CE 4. Just make sure you are using the RTM version because there was a problem with bin-deployment in betas. Also see Scott Gu's blog post about it.
ASP.NET MVC 3 can also be bin-deployed if your hosting provider doesn't have the assemblies installed in the GAC. All that's need is .NET 4.0.
This being said SQL CE is an embedded database and not designed to work in a heavy multithreaded environments such as ASP.NET. It is good for development and light-usage scenarios. For high-volume sites and applications you'll probably want to migrate it to use SQL Server Express or SQL Server.

Resources