TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mubarak Suleiman
NA
10
1.2k
where and what to add picture property
Mar 27 2018 3:12 AM
Hi,
i am working on project and i want to picture property on identityModel.cs, i don't know where to add and what to add? i am very new to EF. i was just following a video to practise and i don't want to skip any step.
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
SocialSiteManager.Models;
namespace
SocialSiteManager.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
string
Picture {
get
;
set
; }
}
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
SocialSiteManager
{
public
static
class
IdentityHelper
{
// Used for XSRF when linking external logins
public
const
string
XsrfKey =
"XsrfId"
;
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
Reply
Answers (
0
)
How to select random id from database and display randomly o
outlook add in and read outlook mail attachments using c#