I'm learning OAuth2 via this tutorial, then I found refresh token's expire time is the same as access token, is this correct?
I'm learning OAuth2 via this tutorial, then I found refresh token's expire time is the same as access token, is this correct?
That's true: refresh tokens issued by the OAuth2 authorization server built in OWIN/Katana always have the same expiration date as access tokens ; even if you specify an explicit ExpiresUtc
property in AuthenticationProperties
when you call IOwinContext.Authentication.SignIn(identity, properties)
That's not really convenient for the reasons @Hans mentioned but you can override this behavior in AuthenticationTokenProvider.CreateAsync
(the class you use for OAuthAuthorizationServerOptions.RefreshTokenProvider
):
Simply set context.Ticket.Properties.ExpiresUtc
with the expiration date of your choice, and the refresh token will be issued with a different expiration date:
public class RefreshTokenProvider : AuthenticationTokenProvider {
public override void Create(AuthenticationTokenCreateContext context) {
context.Ticket.Properties.ExpiresUtc = // set the appropriate expiration date.
context.SetToken(context.SerializeTicket());
}
}
You can also take a look at AspNet.Security.OpenIdConnect.Server
, a fork of the OAuth2 authorization server offered by OWIN/Katana that has a native RefreshTokenLifetime
: https://github.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Server/tree/dev
app.UseOpenIdConnectServer(options => {
// Essential properties omitted for brevity.
// See https://github.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Server/tree/dev/samples/Mvc for more information.
// RefreshTokenLifetime allows you to define a lifetime specific to refresh tokens,
// which is totally independent of the lifetime used for access tokens.
options.RefreshTokenLifetime = TimeSpan.FromDays(14);
});
Don't hesitate to ping me if you need help.
The system.webServer section in the Web.config file specifies settings for IIS 7.0 that are applied to the Web application. The system.WebServer is a child of the configuration section. For more information, see IIS 7.0: system.webServer Section Group (IIS Settings Schema). and <system.web> specifies the root element for the ASP.NET configuration...
asp.net,ajax,webforms,updatepanel
I have just tested your code and seems to be working with some test modifications: ASPX <asp:UpdatePanel ID="UP_Panel" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:DropDownList ID="ddlSwitch" runat="server" Width="250px" AutoPostback="true" OnSelectedIndexChanged="ddlSwitch_SelectedIndexChanged"> <asp:ListItem Value="continent" Text="Continent"></asp:ListItem> <asp:ListItem Value="region" Text="Region"></asp:ListItem> <asp:ListItem Value="country"...
c#,css,asp.net,twitter-bootstrap
You just miss a little thing i.e. to assign a Validation Group to your buttons and your RequiredFieldValidators. Your code should be: <div class="container"> <h2>Registration</h2> <p>Please fill out the forms to complete your registration.</p> <form role="form"> <div class="form-group"> <label for="username">Name:</label> <asp:TextBox runat="server" ID="UserName" CssClass="form-control" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"...
asp.net,vb.net,visual-studio-2012,converter
The result isn't wrong, it only has lower precision than you expected. Floating point numbers have a limited precision by design, and you simply can't expect to get a result that is more precise than its limit. You can use a Decimal to get higher precision. In this case it...
javascript,c#,asp.net,webmethod,pagemethods
You PageMethod is looking like this PageMethods.LoginUser(onSuccess, onFailure, email, pass); And when you call it, it looks like this PageMethods.LoginUser(email, pass); Your arguments should be in the same order as the method. PageMethods.LoginUser(email, pass, onSuccess, onFailure); ...
You should pass the variable to state. In the callback argument, you can parse your variable from state argument. For example, https://accounts.google.com/o/oauth2/auth?scope=email profile&state={"user_id": 1}&redirect_uri=http://localhost&response_type=code&client_id=xxxxxxxx.apps.googleusercontent.com&approval_prompt=force The callback url will be http://localhost/code?state={"user_id": 1}&code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7...
The module- and application pipelines are explained in detail in the wiki. It's basically hooks which are executed before and after route execution on a global (application pipelines) and per-module basis. Here's an example: If a route is resolved to a module called FooModule, the pipelines will be invoked as...
There are several domain providers like: godaddy, name etc you can use to buy a domain name. These providers also provide you steps to map the domain name to your website. Check out this link for example. This link explains domain name configuration in details.
You've got a quotes problem, fix it like this: <% Session["path"] = "'" + vr_ + "'"; %> EDIT 1: Javascript and ASP.NET are not the same, so you cannot access the variables, so you can't do it on the client side. You must send something to the server like...
c#,asp.net,asp.net-mvc,c#-4.0,reporting-services
Use formatting: DateTime.Now.ToString("dddd, dd-MM-yy"); Output: Montag, 15-06-15 //Written day of week in your local culture. To edit the axis labeling, you can do it in your code-behind file: Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "dddd, dd-MM-yy"; Or in your markup: <ChartAreas> <asp:ChartArea Name="ChartArea1"> <AxisX Title="Date" IsLabelAutoFit="True" TitleForeColor="#ff0000"> <LabelStyle Format="dddd, dd-MM-yy" /> <MajorGrid Enabled ="False"...
sql,asp.net,asp.net-mvc,database,entity-framework-6
Ideally what you want is a many-to-many relationship between your Shop and Product entities: public class Shop { public int ShopId {get; set;} public virtual ICollection<ShopProduct> ShopProducts {get; set;} } public class Product { public int ProductId {get; set;} public string Name {get; set;} public virtual ICollection<ShopProduct> ShopProducts {get; set;}...
You don't need to JSON.stringify the recipients. "recipients": JSON.stringify("[{'firstname':'a','lastname':'b','email':'c','voucheramount':'d'}]") Remove JSON.stringify form here and it should work. var postData = { "workplaceGiverId": $(".wpgDropdownList").val(), "fromMemberId": $(".wpgFromMemberDropdownList").val(), "toMemberId": $(".wpgToMemberDropdownList").val(), "voucherExpiryDate": $("#expiryDatePicker").val(), "recipients": [{'firstname':'a','lastname':'b','email':'c','voucheramount':'d'}] }; ...
If you set "Enable Integrated Windows Authentication" (which is the default), and the server requires integrated Windows authentication, then the user will be authenticated silently using current default credentials, if possible. If you disable Integrated Windows Authentication, the user will be prompted to supply credentials. See this KB article for...
First verify that the World Wide Web Publishing Service is installed and not disabled. [Source:MSDN] Right-click My Computer on the desktop, and then click Manage. Expand the Services and Applications node, and then click the Services node. In the right pane, locate the World Wide Web Publishing Service. If the...
May be this post will help you to change color of grid but keep AXIS same Visual Studio 2010 Chart control - line color. For line style Chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = System.Web.UI.DataVisualization.Charting.ChartDashStyle.Dash; ...
You can solve this using the attribute colspan on the td tag: <table border = "1"> <tr> <td colspan="2"> Do you love peanuts? This is a very important question. </td> </tr> <tr> <td> Yes, I do. </td> <td> No, I don't. </td> </tr> </table> Check this link ...
Here is an example of what I meant: (Oh and, forgive the images please :) ) #field1,#field2{ display:none; } #field1 + label { padding:40px; padding-left:100px; background:url(http://www.clker.com/cliparts/M/F/B/9/z/O/nxt-checkbox-unchecked-md.png) no-repeat left center; background-size: 80px 80px; } #field1:checked + label { background:url(http://www.clker.com/cliparts/B/2/v/i/n/T/tick-check-box-md.png) no-repeat left center; background-size: 80px 80px; } #field2 + label { padding:40px;...
c#,asp.net,.net,entity-framework,entity-framework-6
You are executing an asynchronous method. This means that any exceptions will be thrown when you call await on the returned task or when you try to retrieve the results using await myTask; You never do so, which means that the exception is thrown and caught higher up your call...
Hi here the problem is with your random function. If you want to make sure one question will get repeated only after all the questions have shown atleast one. step 1: keep a array with length equal to the number of question. step 2: get a random question . step...
I haven't personally worked with an Oracle database, but from your stack trace I see the following error: Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed. Take a look at this similar...
Best way to do it is by using a stored proceed rather than a sql statement in C# code. You are getting error because the referenced records are still present in referenced table and are using cmd.ExecuteReader(); rather than cmd.ExecuteNonQuery();. So you need to delete records for DBS2_MOVIE WHERE MOVIE_ID...
Sure, assuming you are using IIS to host your site, open IIS Manager and select your web site and then binding on the right: make sure you only have a binding for https not for http. This way IIS will only send https traffic to that web site. Edit: What...
asp.net,sql-server,parameter-passing
If doing it from codebehind works then you can do something like sdsOrderErrors.SelectCommand = string.Format("SELECT {0} AS fld FROM [a_table]", colName); (OR) Have a stored procedure to accept a parameter and perform a dynamic query to achieve the same like create procedure usp_testSelect(@colname varchar(30)) as begin declare @sql varchar(200); set...
You can't do this: string.Contains(string array) Instead you have to rewrite that line of code to this: if (file == null || formats.Any(f => file.Contains(f))) And this can be shortened down to: if (file == null || formats.Any(file.Contains)) ...
try this: var loginName = @"loginNameOfInterestedUser"; var ldap = new DirectoryEntry("LDAP://domain.something.com"); var search = new DirectorySearcher(ldap) { Filter = "(&(objectCategory=person)(objectClass=user)(sAMAccountName=" + loginName + "))" }; var result = search.FindOne(); if (result == null) return; var fullQuery = result.Path; var user = new DirectoryEntry(fullQuery); DirectoryEntry manager; if (user.Properties.PropertyNames.OfType<string>().Contains("manager")) { var managerPath...
The error is self explanatory. Take a look at this: https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.insertitemtemplate(v=vs.110).aspx So you can do either of these things. Create an InsertItemplate and insert using the ItemInserted event of the listview Change the CommandName to CommandName="InsertData" and catch that event on the ItemCommand ...
c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor
ViewBag is used when returning a view, not when redirecting to another action. Basically it doesn't persist across separate requests. Try using TempData instead: TempData["Tag"] = post.SelectedTag.ToString(); and in the view: <p><strong>Tag: @TempData["Tag"]</strong></p> ...
c#,jquery,asp.net,scriptmanager,registerstartupscript
All you need to do is add a semi-colon to the end of your String.Format call. ScriptManager.RegisterStartupScript(this, this.GetType(), "ScriptManager1", String.Format(@"ShowHideMessageBlock('{0}');", @"#successMsg"), true); ...
Try this vb code behind, then comment out my test Private Sub BindGrid() Dim dt_SQL_Results As New DataTable '' Commenting out to use test data as I have no access to your database 'Dim da As SqlClient.SqlDataAdapter 'Dim strSQL2 As String 'Dim Response As String = "" 'strSQL2 = "SELECT...
c#,asp.net,asp.net-mvc,authentication
It's because of your ViewBag's returnUrl sets null after postback, just simply put ViewBag.ReturnUrl = returnUrl; at the beginning of your HttpPost verb of Login action. ...
sql,asp.net,sql-server,subquery,sqlxml
Change XML PATH('') to XML PATH('tag')
c#,asp.net,asp.net-mvc,tinymce
Your missing an @symbol for the id attribute: Modify your script as well like this: ***EDIT some thing seems off about the radio buttons only one should be checked and they should have the same name ** you can use the # to denote and ID in Jquery by the...
It looks like you are missing client in: $hub.client.onRecieveNotification = function (message) { $("#message").append($("<li></li>", { text: message })); } ...
c#,asp.net,asp.net-mvc,entity-framework
If you don't specify a database name then the connection will use the default database for the user, in this case it's integrated security so it's your Windows login. As you likely have full system admin on the server the default database will be master so you will find all...
The solution is to force IIS to write the changes from the cache into the Metabase.xml, this way the new configurations will be available for editing. This is done using the command - %systemroot%\system32\IIsCnfg.vbs /save ...
INSERT INTO tbl2 ( Name ,parentId ) SELECT DISTINCT manager ,0 FROM tbl1 WHERE manager NOT IN ( SELECT employee FROM tbl1 ) INSERT INTO tbl2 SELECT DISTINCT employee ,0 FROM tbl1 UPDATE tbl2 SET parentid = parent.id FROM tbl2 INNER JOIN tbl1 ON tbl2.Name = tbl1.employee INNER JOIN tbl2...
I would use a separate div and use fixed positioning on it. Example <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Layout Example</title> <link rel="stylesheet" type="text/css" href="./Layout Example_files/style.css"> <style type="text/css"> .fixed-background{ background: url( "images/SoapBubbles.jpg" ) no-repeat fixed top center; position:fixed; z-index:-1; top:0; right:0; left:0; bottom:0; } </style> </head> <body> <div...
The WebApi is a web project and on compiling it creates a dll. It is not a class library or a nuget package to consume and use it. I have practically implemented this in a real world application and below are my thoughts for your understanding. Your question is Once...
c#,asp.net,asp.net-mvc,asp.net-5,asp.net-mvc-6
The best way is to create a composite wrapper: public class Wrapper { public ModelA A { get; set; } public ModelB B { get; set; } } Put Wrapper in the parameter list and mark that [FromBody]. You can't use that attribute more than once because all of the...
You are using a namespace, your full type name is Project.ViewModel.ViewModel (namespace is Project.ViewModel and class name is ViewModel) so use this using instead: @model Project.ViewModel.ViewModel ...
asp.net,linq,entity-framework,asp.net-identity
In c# you can get all users that are not in a certain role like this: var role = context.Roles.SingleOrDefault(m => m.Name == "role"); var usersNotInRole = context.Users.Where(m => m.Roles.All(r => r.RoleId != role.Id)); ...
You need to use InnerHtml property HtmlGenericControl li = new HtmlGenericControl("li"); li.ID = "liQuestions" + recordcount.ToString(); li.Attributes.Add("role", "Presentation"); ULRouting.Controls.Add(li); HtmlGenericControl anchor = new HtmlGenericControl("a"); li.Attributes.Add("myCustomIDAtribute", recordcount.ToString()); anchor.InnerHtml = "Test <br/> 12345"; li.Controls.Add(anchor); Or, like this: anchor.Controls.Add(new LiteralControl("Test")); //or new Literal("Test"); anchor.Controls.Add(new HtmlGenericControl("br"));...
protected member is accessible by derived class instances and there's nothing special about it. Nothing special in the class itself, either @ WebSocketHandler.cs. It just mens you need to pass in a nullable type, it does not mean it can't get any arguments. int? maxIncomingMessageSize = 0; var socket =...
No, you cannot enter any string. You will need to register with each provider to get the parameters that you need. See http://www.asp.net/web-api/overview/security/external-authentication-services for instructions on how to do this....
c#,jquery,asp.net,table,checkbox
you can try this code List<CheckBox> lstChckBox; protected void Page_Load(object sender, EventArgs e) { // you can create controls programaticaly or html page, doesnt important //only you should know controls ID and all controls share same checked event CheckBox chc1 = new CheckBox(); chc1.CheckedChanged += new EventHandler(chck_CheckedChanged); CheckBox chc2 =...
asp.net,azure,azure-mobile-services
It is entirely possible to move the .NET runtime - This is just an ASP.NET Web API site, and it can be hosted anywhere that you might run ASP.NET. However, some features such as the login functionality will not be available. For the Node.JS runtime, the actual process running the...
c#,asp.net,sql-server,date,gridview-sorting
What happens if you change all of the filters to use 'LIKE': if (DropDownList1.SelectedValue.ToString().Equals("Start")) { FilterExpression = string.Format("Start LIKE '{0}%'", TextBox1.Text); } Then, you're not matching against an exact date (at midnight), but matching any date-times which start with that date. Update Or perhaps you could try this... if (DropDownList1.SelectedValue.ToString().Equals("Start"))...
c#,asp.net,asp.net-mvc,json.net
Does the assemblyBinding tag have proper xmlns schema? Check if the issue you are encountering is same as Assembly binding redirect does not work
asp.net,architecture,wcfserviceclient
As long as you are able to use the exact same contract for all the versions the web application does not need to know which version of the WCF service it is accessing. In the configuration of the web application, you specify the URL and the contract. However, besides the...