locked
createIdentify error RRS feed

  • Question

  • User-605499000 posted

    The type for methods User Management Extensions CreateIdentify cannot be inferred from the usage. Try specifying the type arguments explicitly. 

    This is under a IdentityModel.cs. Below is the file.

    using System;
    using System.Security.Claims;
    using System.Threading.Tasks;
    using System.Web;
    using Microsoft.AspNet.Identity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using Microsoft.AspNet.Identity.Owin;
    using Microsoft.Owin.Security;
    using Bumples.Models;

    namespace Bumples.Models
    {
    // You can add User data for the user by adding more properties to your User class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
    public class ApplicationUser : IdentityUser
    {
    public ClaimsIdentity GenerateUserIdentity(ApplicationUserManager manager)
    {
    // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
    var userIdentity = manager.CreateIdentity(this, DefaultAuthenticationTypes.ApplicationCookie);
    // Add custom user claims here
    return userIdentity;
    }

    public Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager)
    {
    return Task.FromResult(GenerateUserIdentity(manager));
    }
    }

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
    public ApplicationDbContext()
    : base("DefaultConnection", throwIfV1Schema: false)
    {
    }

    public static ApplicationDbContext Create()
    {
    return new ApplicationDbContext();
    }
    }
    }

    #region Helpers
    namespace Bumples
    {
    public static class IdentityHelper
    {
    // Used for XSRF when linking external logins
    public const string XsrfKey = "XsrfId";

    public static void SignIn(ApplicationUserManager 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.QueryString[ProviderNameKey];
    }

    public const string CodeKey = "code";
    public static string GetCodeFromRequest(HttpRequest request)
    {
    return request.QueryString[CodeKey];
    }

    public const string UserIdKey = "userId";
    public static string GetUserIdFromRequest(HttpRequest request)
    {
    return HttpUtility.UrlDecode(request.QueryString[UserIdKey]);
    }

    public static string GetResetPasswordRedirectUrl(string code, HttpRequest request)
    {
    var absoluteUri = "/Account/ResetPassword?" + CodeKey + "=" + HttpUtility.UrlEncode(code);
    return new Uri(request.Url, absoluteUri).AbsoluteUri.ToString();
    }

    public static string GetUserConfirmationRedirectUrl(string code, string userId, HttpRequest request)
    {
    var absoluteUri = "/Account/Confirm?" + CodeKey + "=" + HttpUtility.UrlEncode(code) + "&" + UserIdKey + "=" + HttpUtility.UrlEncode(userId);
    return new Uri(request.Url, absoluteUri).AbsoluteUri.ToString();
    }

    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

    Hope you can help me,

    Thanks

    Jen

    Thursday, October 18, 2018 8:51 PM

Answers

  • User-605499000 posted

    Thank you for your help. I think I found the answer to it.

    Jen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 22, 2018 1:10 AM

All replies

  • User409696431 posted

    Where does the error occur?   "CreateIdentify" does not exist in the code you posted.

    Thursday, October 18, 2018 10:33 PM
  • User-605499000 posted

    sorry 2nd line after manager Createidentity

    var userIdentity = manager.CreateIdentity  

    Thanks Jen

    Thursday, October 18, 2018 11:53 PM
  • User-605499000 posted

    Thank you for your help. I think I found the answer to it.

    Jen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 22, 2018 1:10 AM