小编Ole*_* Sh的帖子

Jade:如何包含javascript文件

我需要在网页中加入一个javascript文件.我写了以下内容:

include /../scripts/jquery.timeago.js
Run Code Online (Sandbox Code Playgroud)

但我明白了

<script>/*
 * timeago: a jQuery plugin, version: 0.8.2 (2010-02-16)
 * @requires jQuery v1.2.3 or later
 *
 * Timeago is a jQuery plugin that makes it easy to support automatically
 * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
 *
 * For usage and examples, visit:
 * http://timeago.yarp.com/
 *
 * Licensed under the MIT:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright (c) 2008-2010, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
 */
(function($) {
....
</script> …
Run Code Online (Sandbox Code Playgroud)

express pug

51
推荐指数
3
解决办法
6万
查看次数

ASP.NET标识更改密码

我需要能够通过管理员更改用户的密码.因此,管理员不应输入用户的当前密码,他应该有能力设置新密码.我查看ChangePasswordAsync方法,但此方法需要输入旧密码.因此,此方法不适合此任务.因此我通过以下方式制作:

    [HttpPost]
    public async Task<ActionResult> ChangePassword(ViewModels.Admin.ChangePasswordViewModel model)
    {
        var userManager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
        var result = await userManager.RemovePasswordAsync(model.UserId);
        if (result.Succeeded)
        {
            result = await userManager.AddPasswordAsync(model.UserId, model.Password);
            if (result.Succeeded)
            {
                return RedirectToAction("UserList");
            }
            else
            {
                ModelState.AddModelError("", result.Errors.FirstOrDefault());
            }
        }
        else
        {
            ModelState.AddModelError("", result.Errors.FirstOrDefault());
        }
        return View(model);
    }
Run Code Online (Sandbox Code Playgroud)

它有效,但理论上我们可以在AddPasswordAsync方法上收到错误.因此,旧密码将被删除,但未设置新密码.这不好.有什么方法可以在"一次交易"中做到吗?PS.我看到ResetPasswordAsync方法带有重置令牌,似乎,它更安全(因为不能与用户不稳定的情况)但无论如何,它通过2个动作.

c# reset-password asp.net-mvc-5 asp.net-identity-2

49
推荐指数
6
解决办法
6万
查看次数

为什么ASP.NET Core中的中间件需要特定的语义,而不是接口?

众所周知,ASP.NET Core中方法Configure(类Startup)的IApplicationBuilder需要特定的语义(使用HttpContext类型的输入参数和作为返回值的Task的方法'Invoke').但为什么它没有作为接口实现?我可以写类似的东西:

public class FakeMiddleware
{

}
Run Code Online (Sandbox Code Playgroud)

并注册:

    app.UseMiddleware<FakeMiddleware>();
Run Code Online (Sandbox Code Playgroud)

我们会得到一个运行时错误.当然,它是微不足道的东西,易于找到和修复,但它实现如此粗糙,没有界面?

middleware interface owin owin-middleware asp.net-core

29
推荐指数
2
解决办法
1476
查看次数

CookieAuthenticationOptions,ExpireTimeSpan不起作用

我有以下代码:

    public void ConfigureAuth(IAppBuilder app)
    {
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            ExpireTimeSpan = System.TimeSpan.FromMinutes(1),
            LoginPath = new PathString("/Account/Login"),
            LogoutPath = new PathString("/Account/LogOff")
        });
Run Code Online (Sandbox Code Playgroud)

但登录会话活动超过1分钟.此外,时间到期时不会调用LogoutPath.为什么?

authentication asp.net-mvc-5

15
推荐指数
2
解决办法
2万
查看次数

Swagger Swashbuckle Asp.NET Core:显示有关使用的每个枚举的详细信息

我有以下枚举:

public enum TicketQuestionType
{
    General = 1,
    Billing = 2,
    TMS = 3,
    HOS = 4,
    DeviceManagement = 5
}
Run Code Online (Sandbox Code Playgroud)

和模型类:

public class TicketCreateApi
{
    public string Subject { get; set; }
    public TicketQuestionType QuestionType { get; set; } = TicketQuestionType.General;
    public TicketType Type { get; set; } = TicketType.Problem;
    public TicketStatus Status { get; set; } = TicketStatus.New;
    public TicketPriority Priority { get; set; } = TicketPriority.Normal;
    public string Description { get; set; }
    public List<string> Attachments { …
Run Code Online (Sandbox Code Playgroud)

asp.net-web-api swagger swashbuckle asp.net-core swashbuckle.aspnetcore

15
推荐指数
1
解决办法
1万
查看次数

Razor语法中的ValidateRequest

我有以下headerASP.Net MVC页面:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<NEOGOV_Ideas.Models.SubIdeaAdminPage>"
ValidateRequest="false" %>
Run Code Online (Sandbox Code Playgroud)

我需要将此页面移动到Razor语法.我该如何设置ValidateRequest?谢谢

razor asp.net-mvc-3

12
推荐指数
2
解决办法
1万
查看次数

WiX - 安装后启动应用程序

我读了一篇文章http://wix.sourceforge.net/manual-wix3/run_program_after_install.htm并且它有效.

<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch MS" />
<Property Id="WixShellExecTarget" Value="[#MainExe]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

<UI Id="MyWixUI_Mondo">
  <UIRef Id="WixUI_Minimal" />
  <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
  <UIRef Id="WixUI_ErrorProgressText"/>
</UI>
Run Code Online (Sandbox Code Playgroud)

但我想默认选中复选框,而不是未选中.怎么做

wix autostart

8
推荐指数
1
解决办法
3889
查看次数

WPF TabItem的IsSelected属性

我有以下代码:

<TabItem Name="tabItemGeneral">
    <TabItem.Triggers>
        <Trigger Property="IsSelected" Value="True">
            <Setter TargetName="tabGeneralImg" Property="Source" Value="Image/tabGeneralActive.png"></Setter>
        </Trigger>
    </TabItem.Triggers>
    <TabItem.Header>
        <StackPanel Orientation="Horizontal" Margin="0,-3,0,0">
            <Image Name="tabGeneralImg" Source="Images/tabGeneral.png" Width="11" Height="11"></Image>
            <Label Name="tabGeneralLbl" Content="General"></Label>
        </StackPanel>
    </TabItem.Header>
    <Grid>
        <!-- ... -->
    </Grid>
</TabItem>
Run Code Online (Sandbox Code Playgroud)

但我得到错误1'IsSelected'成员无效,因为它没有合格的类型名称.C:\ MyNET\bluetooth\iLockWPF\iLock\iLock\MainWindow.xaml 63 60 iLock

在编译期间.为什么?

wpf tabitem

7
推荐指数
1
解决办法
1万
查看次数

Swashbuckle.AspNetCore 需要的查询字符串参数

我有一个带有Swashbuckle.AspNetCore包的 ASP.NET Core v2.1 项目。我的代码是:

    /// <summary>
    /// Set new android token for the current driver
    /// </summary>
    /// <remarks>
    /// Sample request:
    ///
    ///     PUT /SetToken?token=new_token
    ///
    /// </remarks>
    /// <param name="token">can't be null or empty</param>
    /// <returns></returns>
    /// <response code="204">If executed successfully</response>
    /// <response code="400">if token is null or empty</response>  
    /// <response code="404">if user is not a driver; if driver is not found (removed etc); if user does not have a profile</response>  
    [ProducesResponseType(204)]
    [ProducesResponseType(400)]
    [ProducesResponseType(404)]
    [HttpPut] …
Run Code Online (Sandbox Code Playgroud)

swagger swashbuckle asp.net-core

7
推荐指数
1
解决办法
2441
查看次数

无法编译 - 找不到Request.Content.IsMimeMultipartContent()

我有以下代码:

   public class UploadController : ApiController
{
    DBRepository _repository = new DBRepository();


    public Task<IEnumerable<FileDesc>> Post()
    {
        string folderName = "UploadedFiles";
        string PATH = HttpContext.Current.Server.MapPath("~/" + folderName);
        PATH = @"c:\www\qqq";
        string rootUrl = Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.AbsolutePath, String.Empty);


        if (Request.Content.IsMimeMultipartContent())
        {
            var streamProvider = new CustomMultipartFormDataStreamProvider(PATH);

            var task = Request.Content.ReadAsMultipartAsync(streamProvider).ContinueWith<IEnumerable<FileDesc>>(t =>
            {

                if (t.IsFaulted || t.IsCanceled)
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }


                return fileInfo;
            });

            return task;
        }
        else
        {
            throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted"));
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

但是我得到了错误:

错误16'System.Net.Http.HttpContent'不包含'IsMimeMultipartContent'的定义,并且没有可以找到接受类型'System.Net.Http.HttpContent'的第一个参数的扩展方法'IsMimeMultipartContent'(你错过了吗?使用指令或程序集引用?)

错误17'System.Net.Http.HttpContent'不包含'ReadAsMultipartAsync'的定义,并且没有可以找到接受类型'System.Net.Http.HttpContent'的第一个参数的扩展方法'ReadAsMultipartAsync'(你错过了吗?使用指令或程序集引用?) …

asynchronous system.net

6
推荐指数
1
解决办法
3251
查看次数