我使用Visual Studio 2013附带的Web Api 2模板有一些OWIN中间件来进行用户身份验证等.
在OAuthAuthorizationServerOptions我注意到,OAuth2服务器设置为分发在14天后到期的令牌
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/api/token"),
Provider = new ApplicationOAuthProvider(PublicClientId,UserManagerFactory) ,
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
AllowInsecureHttp = true
};
Run Code Online (Sandbox Code Playgroud)
这不适合我的最新项目.我想分发可以使用a刷新的短暂bearer_tokensrefresh_token
我做了很多谷歌搜索,找不到任何有用的东西.
所以这就是我设法得到的.我现在已经达到了"WTF do I now"的地步.
我写了一个根据类的属性RefreshTokenProvider实现:IAuthenticationTokenProviderRefreshTokenProviderOAuthAuthorizationServerOptions
public class SimpleRefreshTokenProvider : IAuthenticationTokenProvider
{
private static ConcurrentDictionary<string, AuthenticationTicket> _refreshTokens = new ConcurrentDictionary<string, AuthenticationTicket>();
public async Task CreateAsync(AuthenticationTokenCreateContext context)
{
var guid = Guid.NewGuid().ToString();
_refreshTokens.TryAdd(guid, context.Ticket);
// hash??
context.SetToken(guid);
}
public async Task …Run Code Online (Sandbox Code Playgroud) 我有一个两步形式的过程,其中第一组数据存储在会话中.
[IsMp4File]
[Required(ErrorMessage = "* Please select a video to upload")]
public HttpPostedFileBase VideoClip { get; set; }
[Required(ErrorMessage = "* Please select a thumbmail image")]
public HttpPostedFileBase VideoThumbnail{ get; set; }
public string VideoFileName { get { return VideoClip.FileName; } }
public NewsWizardStep CurrentStep { get; set; }
Run Code Online (Sandbox Code Playgroud)
...
public enum NewsWizardStep : int
{
One = 1,
Two = 2,
Three = 3,
Four = 4,
Five = 5,
Six = 6
}
Run Code Online (Sandbox Code Playgroud)
调节器
public ActionResult TvCreate(TvNewsVideoVM modelVM) …Run Code Online (Sandbox Code Playgroud) 问题背景
为了避免重复验证逻辑,我遵循将服务器端ModelState错误推送到我的View Model(MVVM KnockoutJS)的模式.
因此按照惯例,我的KOViewModel 上的属性名称匹配我的Api正在暴露和期待的属性,因此我可以使用我编写的一个小的Knockout插件轻松地将一个映射到另一个.
<validation-summary params="vm: $data, class: 'alert alert-error'"></validation-summary>
...
<div class="control-group" data-bind="errorCss: {'error': spend }">
<label class="control-label" for="spend">Spend</label>
<div class="controls">
<div class="input-prepend">
<span class="add-on">$</span>
<input type="text" data-bind="value: spend" id="spend" class="input-medium" placeholder="Spend USD" />
</div>
<validation-message params="bind: spend, class: 'text-error'"></validation-message>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
问题
问题对我来说,当JSON.Net串行化我通过和AJAX发送JSON,当它遇到异常就其加入到ModelState为与Exception上ModelError类.
响应示例:
{
"message": "The request is invalid.",
"modelState": {
"cmd.spend": [
"Error converting value \"ii\" to type 'System.Double'. Path 'spend', line 1, position …Run Code Online (Sandbox Code Playgroud) 已经玩过一段时间的windows azure,我非常喜欢它,但大多数网站的一个常见要求是提供一个网络邮件和POP/IMAP解决方案,就像你从godaddy传统的共享网络托管一样.
由于任何人都有这方面的解决方案,我正在设法为拥有域的客户提供具有POP和IMAP访问权限的Web邮件平台.
谢谢
我正在使用Visual Studio 2017 RC并启动了一个针对完整.NET Framework的新ASP.NET Core项目.
这行代码不会编译.
dynamic handler = _container.GetService(handlerType);
if (handler == null) _logger.LogError("Can't find handler to handle " + cmd.GetType().Name);
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
CS0656 Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'
Run Code Online (Sandbox Code Playgroud)
经过一些谷歌搜索后,看起来这是因为我错过了Microsoft.CSharp程序集.有很多人偶然发现了他的问题,但似乎没有使用.NET Core 1.1.
所以我做了这个Install-Package Microsoft.CSharp并获得了4.3.0版本.我的项目仍然无法建立.
如果我将程序集引用添加到Microsoft.CSharp(GAC的版本),那么它将编译并运行.
这是一个Bug吗?我原本期望NuGet包能解决这个问题吗?
嗨,我已在我的网络配置中添加提供程序,如下所示:
<add name="MvcSiteMapProvider"
type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider"
siteMapFile="~/Sitemap/SiteMap.sitemap"
securityTrimmingEnabled="true"
enableLocalization="true"
scanAssembliesForSiteMapNodes="true"
skipAssemblyScanOn=""
attributesToIgnore="bling"
nodeKeyGenerator="MvcSiteMapProvider.DefaultNodeKeyGenerator, MvcSiteMapProvider"
controllerTypeResolver="MvcSiteMapProvider.DefaultControllerTypeResolver, MvcSiteMapProvider"
actionMethodParameterResolver="MvcSiteMapProvider.DefaultActionMethodParameterResolver, MvcSiteMapProvider"
aclModule="MvcSiteMapProvider.DefaultAclModule, MvcSiteMapProvider"
siteMapNodeUrlResolver="MvcSiteMapProvider.DefaultSiteMapNodeUrlResolver, MvcSiteMapProvider"
siteMapNodeVisibilityProvider="MvcSiteMapProvider.DefaultSiteMapNodeVisibilityProvider, MvcSiteMapProvider"
Run Code Online (Sandbox Code Playgroud)
这是我的.sitemap文件
<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">
<mvcSiteMapNode title="Classifieds" controller="Classifieds" action="Index" changeFrequency="Always" updatePriority="Normal">
<mvcSiteMapNode title="Category" controller="Classifieds" action="ClassifiedSelection" dynamicNodeProvider="MySite.Helpers.ClassifiedCatDynamicNodeProvider, MySite.Helpers" >
<mvcSiteMapNode title="SpecificAd" controller="Classifieds" action="SpecificClassified" dynamicNodeProvider="MySite.Helpers.ClassifiedAdsDynamicNodeProvider, MySite.Helpers" >
<mvcSiteMapNode title="Email Seller" controller="Classifieds" action="EmailSeller" />
</mvcSiteMapNode>
</mvcSiteMapNode>
</mvcSiteMapNode>
</mvcSiteMap>
Run Code Online (Sandbox Code Playgroud)
我在一个单独的类文件中创建了两个动态prodiders-我的基本相同.(如此处所示http://mvcsitemap.codeplex.com/wikipage?title=Dynamic%20sitemaps&version=1)
我无法让站点地图完全工作,每当我使用站点地图加载页面时,我都会得到一个值不能为空的错误.
请帮助,我虽然MvcSitemap会调用我的dynamicNodeprovider,但它并不是因为我所创建的两个类中都没有beakpoints,
请帮忙.
我想将htmlAttributes作为一个object类似的方法传递给...
foo.HtmlAttributes(new { data_bind = "foo"});
Run Code Online (Sandbox Code Playgroud)
在所有的MVC HtmlHelpers中,我使用下划线作为连字符,这将输出有效的html "data-bind"
在幕后,这是根据以下问题进行的:
public virtual void HtmlAttributes(object htmlAttributes)
{
this.Attributes = new RouteValueDictionary(htmlAttributes);
}
Run Code Online (Sandbox Code Playgroud)
后来这将被称为:
internal virtual void ApplyConfiguration(TagBuilder tag)
{
tag.MergeAttributes(this.Attributes);
}
Run Code Online (Sandbox Code Playgroud)
但是这会输出:
<div data_bind="foo"></div>
Run Code Online (Sandbox Code Playgroud)
如何输出有效的HTML?
更新 感谢Zabavsky ......
public virtual void HtmlAttributes(object htmlAttributes)
{
this.Attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
}
Run Code Online (Sandbox Code Playgroud) double myNumber;
myNumber.ToString("0.:#0").Replace(".", "");
Run Code Online (Sandbox Code Playgroud)
有人能告诉我等效的jquery函数吗?
对不起jquery不好.
谢谢,
用户将鼠标悬停在菜单项上,然后我想向用户显示子菜单.我想使用Jquery来显示和隐藏sub-nav-conatiner div.唯一的麻烦是我的jQuery show并隐藏所有子菜单 - 我想只显示一个.所以我需要选择当前悬停的嵌套div,希望这是有道理的.我尝试了所有种类没有运气:(
<ul>
<li><a href="/classifieds/farming">
Agriculture & Farming</a>
</li>
<li class="sub-menu-header"><a href="#">Test Header </a>
<div class="sub-nav-container">
<div class="sub-panel">
<ul>
<li><a href="">Electrical Goods</a></li>
<li><a href="">Electrical Goods</a></li>
</ul>
<div class="clr"></div>
</div>
</div>
</li>
...
</ul>
Run Code Online (Sandbox Code Playgroud)
jQuery的
$(document).ready(function () {
$('.sub-nav-container').css('display', 'none !important;');
});
$('.sub-menu-header').mouseover(function () {
?????????
});
$('.sub-menu-header').mouseleave(function () {
$('.sub-nav-container').css('display', 'none !important;');
});
Run Code Online (Sandbox Code Playgroud) c# ×7
asp.net-mvc ×4
javascript ×2
jquery ×2
asp.net ×1
asp.net-core ×1
azure ×1
cloud ×1
css ×1
html ×1
html-helper ×1
imap ×1
json.net ×1
oauth-2.0 ×1
owin ×1
webmail ×1