小编Rob*_*lls的帖子

PagedList在第二页上丢失了搜索过滤器

我正在使用http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the中的示例实现一个简单的分页列表索引-entity框架式-AN-ASP净MVC应用程序

我的问题是,当我转到第二页时,搜索字符串"丢失",因此我显示了所有记录,而不是过滤的结果集.

我的index.cshtml:

@using (Html.BeginForm("Index", "", FormMethod.Get))
{
    <p>
        @Html.TextBox("searchString", ViewBag.currentFilter as string, new { @placeholder = "Search by title or author" })
        <input type="submit" value="Search" />
    </p>
}

@if (Model.PageCount > 1)
{ 
    @Html.PagedListPager( Model, page => Url.Action("Index", new { page }) )
}
Run Code Online (Sandbox Code Playgroud)

我的控制器:

public ViewResult Index(string sortOrder, string currentFilter, string searchString, int? page)
    {
        ViewBag.TitleSortParm = sortOrder == "Title" ? "Title desc" : "Title";
        ViewBag.AuthorSortParm = sortOrder == "Author" ? "Author desc" : "Author"; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc entity-framework pagedlist

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

如何将现有的asp.net MVC应用程序与IdentityServer集成?

如何将现有的asp.net MVC应用程序与单独的IdentityServer应用程序集成?

我有一个现有的asp.net MVC站点使用身份2.0进行身份验证.

我现在有第二个运行asp.net Core 1.1的应用程序,它提供与客户端(移动)应用程序通信的API.

我需要在所有3个应用程序中共享身份验证.

从我读过的内容来看,我需要添加SSO,IdentityServer似乎是一个很好的解决方案.我计划将IdentityServer设置为第四个应用程序,并将其连接到新的.net API应用程序和客户端应用程序.

但我找不到任何关于如何让我现有的Asp.net应用程序使用新的身份服务器进行身份验证的示例.

asp.net-mvc asp.net-identity asp.net-core identityserver4

10
推荐指数
1
解决办法
5316
查看次数

在FullCalendar中突出显示所选日期

我正在尝试突出显示FullCalender.io中的选定日期(类似于当前日期).

FullCalendar之后- 突出显示周视图中的特定日期我尝试了以下操作,它基本上是在点击时重新呈现日历,并突出显示日期与点击日期匹配的单元格.

    dayRender: function(date, cell)
    {
        var moment = $('#calendar').fullCalendar('getDate');

        if (moment.get('date') == date.get('date'))
        {
            $(cell).addClass('fc-state-highlight');
        }
        else
        {
            $(cell).removeClass('fc-state-highlight');
        }
    },
    dayClick: function (date, allDay, jsEvent, view) {
        $('#calendar').fullCalendar('render');
    },
Run Code Online (Sandbox Code Playgroud)

但它没有做任何事情.:-(

fullcalendar

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

Angular 5 commands.reduce不是router.navigate中的函数

我发送一个字符串作为我的路由器的链接,例如"/ blog/pages/3"

但是我收到错误"commands.reduce不是函数"

导航确实有效,只是错误显示在控制台中

goToPage(link) {
  this.router.navigate(link);
}
Run Code Online (Sandbox Code Playgroud)

angular

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

在.net核心上创建EF迁移时出现System.IO.FileNotFoundException

我有一个.NET Core 2.2项目,正在尝试设置EF迁移。

运行时:

dotnet ef迁移添加了init --verbose

我收到以下错误:

查找提供程序'Microsoft.EntityFrameworkCore.SqlServer'的设计时服务...使用提供程序'Microsoft.EntityFrameworkCore.SqlServer'的设计时服务。查找程序集“ myproject-api”引用的设计时服务。找不到参考的设计时服务。在程序集“ myproject-api”中查找IDesignTimeServices实现...未找到设计时服务。System.IO.FileNotFoundException:无法加载文件或程序集“ myproject,Culture = neutral,PublicKeyToken = null”。该系统找不到指定的文件。

这是我的csproj文件:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4" />
  </ItemGroup>

</Project>
Run Code Online (Sandbox Code Playgroud)

编辑,这是我的Program.cs

public class Program
{
    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
          WebHost.CreateDefaultBuilder(args)
            .UseKestrel()
            .UseUrls("http://localhost:5004")
            .UseStartup<Startup>();

}
Run Code Online (Sandbox Code Playgroud)

c# entity-framework-core .net-core

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

Layout.cshtml上的ASP.NET MVC搜索框

我已经从http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-创建了搜索表单和结果一个在ASP.NET MVC 应用程序中的框架,该应用程序使用PagedList Nuget包处理分页和排序。

我需要帮助的是如何将搜索表单放在主页上?(_layout.cshtml)?

asp.net-mvc

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

无法在ASP.NET Core 2.0中发布原始类型

我正在将非常简单的json数据发布到.net Core 2.0 API。

当我有这样的方法时,为什么会这样:

public async Task<IActionResult> GetNewToken([FromBody]string id)
Run Code Online (Sandbox Code Playgroud)

然后id为null,但是如果我将其封装在模型中:

public class RandomViewModel
{
    public string id { get; set; }
}

public async Task<IActionResult> GetNewToken([FromBody]RandomViewModel model)
Run Code Online (Sandbox Code Playgroud)

然后我的ID是否正确填充?

c# asp.net-core

5
推荐指数
2
解决办法
1636
查看次数

带有 API 数据的 Highcharts Angular

我正在使用来自https://github.com/highcharts/highcharts-angular的官方 Highcharts 角度包装器并且在我的 Angular 6 项目中使用了一个测试图表。

我遇到的问题是试图让图表仅在我从 api 检索数据后显示。

这是我的 html:

<div class="row">
    <div class="col-md-12" *ngIf="!loading">
        <highcharts-chart 
        [Highcharts]="Highcharts"
        [options]="chartOptions"
        style="width: 100%; height: 400px; display: block;"
    ></highcharts-chart>
        </div>
</div>
Run Code Online (Sandbox Code Playgroud)

这是我的组件

loading = true;
Highcharts: any;
chartOptions: any;


public constructor(
    private dashboardService: DashboardService) {
}

ngOnInit() {
    this.dashboardService.getClaimProviderCountsByMonth()
        .pipe(first())
        .subscribe(
            data => {
                // this.chartOptions.series = [{
                //     data: data
                // }];
                this.Highcharts = Highcharts;
                this.chartOptions = {
                    chart: {
                        type: 'column'
                    },
                    title: {
                        text: 'Stacked column chart' …
Run Code Online (Sandbox Code Playgroud)

highcharts angular

4
推荐指数
1
解决办法
2230
查看次数

无法隐式转换类型'Microsoft.AspNetCore.Mvc.BadRequestObjectResult'

我有一个asp.net core 2.1项目,并且在控制器操作中遇到以下错误:

无法将类型“ Microsoft.AspNetCore.Mvc.BadRequestObjectResult”隐式转换为“ System.Collections.Generic.IList”。存在显式转换(您是否缺少演员表?)

这是我的代码:

[HttpPost("create")]
[ProducesResponseType(201, Type = typeof(Todo))]
[ProducesResponseType(400)]
public async Task<IList<Todo>> Create([FromBody]TodoCreateViewModel model)
{
    if (!ModelState.IsValid)
    {
        return BadRequest(ModelState);   // This is the line that causes the intellisense error
    }

    await _todoRepository.AddTodo(model);
    return await GetActiveTodosForUser();
}


[HttpGet("GetActiveTodosForUser")]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<IList<Todo>> GetActiveTodosForUser(string UserId = "")
{
    if (string.IsNullOrEmpty(UserId))
    {
        UserId = HttpContext.User.FindFirstValue(ClaimTypes.Sid);
    }
    return await _todoRepository.GetAll(UserId, false);
}
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

c# asp.net .net-core

4
推荐指数
3
解决办法
9334
查看次数

在routerlink中间的Angular 6查询参数

你如何将一个参数放入routerlink.

我正在尝试做这样的事情:

<p *ngFor="let supplier of suppliers">
   <a [routerLink]="['/supplier/{{supplier.businessId}}/products']">
        View Products
   </a>
</p>
Run Code Online (Sandbox Code Playgroud)

typescript angular

4
推荐指数
2
解决办法
1034
查看次数