am beginner in ASP.net, just started wintip toy tutorial. I am using Microsoft Visual Studio 2012 for Web. But this tutorial required VS 2013. So kindly guide me
1. VS 2012 for web is valid for this tutorail
2. As i am using VS 2012, so it is not creating Models Folder by default.
3. and there is no Default class IndentityModels.cs in. i am making that class manually but it is giving many errors. i.e
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Owin.Security;
using System.Web;
using System;
using WingtipToys.Models;
namespace WingtipToys.Models
{
public class ApplicationUser : IdentityUser
{
}
public class ApplicationDbContext : IdentityDbContext<applicationuser>
{
public ApplicationDbContext()
: base("DefaultConnection")
{
}
}
#region Helpers
public class UserManager : UserManager<applicationuser>
{
public UserManager()
: base(new UserStore<applicationuser>(new ApplicationDbContext()))
{
}
}
}
namespace WingtipToys
{
public static class IdentityHelper
{
public const string XsrfKey = "XsrfId";
public static void SignIn(UserManager manager, ApplicationUser user, bool isPersistent)
{
IAuthenticationManager authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
var identity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
}
public const string ProviderNameKey = "providerName";
public static string GetProviderNameFromRequest(HttpRequest request)
{
return request[ProviderNameKey];
}
public static string GetExternalLoginRedirectUrl(string accountProvider)
{
return "/Account/RegisterExternalLogin?" + ProviderNameKey + "=" + accountProvider;
}
private static bool IsLocalUrl(string url)
{
return !string.IsNullOrEmpty(url) && ((url[0] == '/' && (url.Length == 1 || (url[1] != '/' && url[1] != '\\'))) || (url.Length > 1 && url[0] == '~' && url[1] == '/'));
}
public static void RedirectToReturnUrl(string returnUrl, HttpResponse response)
{
if (!String.IsNullOrEmpty(returnUrl) && IsLocalUrl(returnUrl))
{
response.Redirect(returnUrl);
}
else
{
response.Redirect("~/");
}
}
}
#endregion
}
Error 3 The type or namespace name 'Owin' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) C:\Users\FAIZA\documents\visual studio 2012\Projects\WintipToys\WintipToys\Models\IdentityModels.cs 3 17 WintipToys
Error 4 The type or namespace name 'IdentityUser' could not be found (are you missing a using directive or an assembly reference?) C:\Users\FAIZA\documents\visual studio 2012\Projects\WintipToys\WintipToys\Models\IdentityModels.cs 11 36 WintipToys
Error 5 The type or namespace name 'IdentityDbContext' could not be found (are you missing a using directive or an assembly reference?) C:\Users\FAIZA\documents\visual studio 2012\Projects\WintipToys\WintipToys\Models\IdentityModels.cs 15 41 WintipToys
Error 1 The type or namespace name 'Identity' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?) C:\Users\FAIZA\documents\visual studio 2012\Projects\WintipToys\WintipToys\Models\IdentityModels.cs 1 24 WintipToys
Error 2 The type or namespace name 'Identity' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?) C:\Users\FAIZA\documents\visual studio 2012\Projects\WintipToys\WintipToys\Models\IdentityModels.cs 2 24 WintipToys
Error 6 The non-generic type 'WingtipToys.Models.UserManager' cannot be used with type arguments C:\Users\FAIZA\documents\visual studio 2012\Projects\WintipToys\WintipToys\Models\IdentityModels.cs 24 32 WintipToys
kindly help me in these errors and also tell me vs 2012 is valid for this tutorial or not.
secondly the class
ProductContext.cs
using System.Data.Entity;
namespace WingtipToys.Models
{
public class ProductContext : DbContext
{
public ProductContext()
: base("WingtipToys")
{
}
public DbSet<category> Categories { get; set; }
public DbSet<product> Products { get; set; }
}
}
is also giving the following error:
Error 1 The type 'System.Data.Objects.ObjectContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. C:\Users\FAIZA\documents\visual studio 2012\Projects\WintipToys\WintipToys\Models\ProductContext.cs 7 16 WintipToys