小编des*_*ati的帖子

MVC Core-UseIIS和UseIISIntegration有什么区别

查看这些代码,它们具有相同的注释,表明它们执行相同的操作:

/// <summary>
/// Configures the port and base path the server should listen on when 
/// running behind AspNetCoreModule. The app will also be configured 
/// to capture startup errors.
/// </summary>
Run Code Online (Sandbox Code Playgroud)

UseIISMicrosoft.AspNetCore.Server.IIS包中,而UseIISIntegration在中Microsoft.AspNetCore.Server.IISIntegration

两者有什么区别?什么时候需要使用一个与另一个?(或两者皆有?)

更新: github上有一个类似的问题,但是那里没有有用的答案:https : //github.com/aspnet/AspNetCore/issues/6197

model-view-controller core asp.net-core-mvc

9
推荐指数
1
解决办法
1856
查看次数

在asp.net核心应用程序中实现了IHostedService,如何在没有IIS首次请求的情况下运行它?

我已经在asp.net核心网站中实现了IHostedService。它运作良好,但问题是我希望在托管服务器启动或IIS服务重新启动时启动它,但除非有第一个对网站的请求进入,否则它不会启动。

  • 该网站托管在IIS 10.0.18版上
  • AppPool处于“始终运行”模式
  • 网站上的“ PreloadEnabled”是“ True”。
  • 将“ .NET CLR版本”设置为“无托管代码”或“ v4.0.xxxxxx”没有帮助。
  • dotnet核心版本为2.2,并安装了dotnet核心托管捆绑包。

更新1: @Arthur建议的“应用程序初始化模块”没有帮助。既不在站点级别,也不在服务器级别。

我使用的配置:

    <applicationInitialization
         doAppInitAfterRestart="true"
         skipManagedModules="false"
         remapManagedRequestsTo="init.htm">
        <add initializationPage="/init.htm" hostName="localhost"/>
    </applicationInitialization>
Run Code Online (Sandbox Code Playgroud)

更新2:这是我实现接口的方式

internal class PaymentQueueService : IHostedService, IDisposable
{
    private readonly ILogger _logService;
    private Timer _timerEnqueue;

    public PaymentQueueService(ILogger logService)
    {
        _logService = logService;
    }

    public Task StartAsync(CancellationToken cancellationToken)
    {
        _logService.LogInformation("Starting processing payments.");

        _timerEnqueue = new Timer(EnqueuePayments, null, TimeSpan.Zero,
            TimeSpan.FromSeconds(10));

        return Task.CompletedTask;
    }

    private void EnqueuePayments(object state)
    {
        _logService.LogInformation("Enqueueing Payments.");
    }

    public Task StopAsync(CancellationToken cancellationToken)
    {
        _logService.LogInformation("Stopping processing …
Run Code Online (Sandbox Code Playgroud)

c# iis .net-core iis-10 asp.net-core

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

Angular typeahead,设置自定义弹出模板

无论如何都要为typeahead-popup设置自定义模板?

"typeahead-template-url"指令仅适用于弹出窗口中的每个匹配项.

这是我的代码:

    <input class="select-location" id="Location" type="text"
 ng-model="model.location" 
 ng-keypress="keypress($event)"
 typeahead="match for match in getLocations($viewValue)"
 typeahead-template-url="matchUrl"/>
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui-typeahead

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

如何在C#中打开一个大文本文件

我有一个包含大约100000篇文章的文本文件.文件结构是:

.Document ID 42944-YEAR:5
.Date  03\08\11
.Cat  political
Article Content 1

.Document ID 42945-YEAR:5
.Date  03\08\11
.Cat  political
Article Content 2

我想在c#中打开这个文件,逐行处理它.我试过这段代码:

String[] FileLines = File.ReadAllText(
                  TB_SourceFile.Text).Split(Environment.NewLine.ToCharArray()); 
Run Code Online (Sandbox Code Playgroud)

但它说:

抛出了类型'System.OutOfMemoryException'的异常.

问题是如何打开此文件并逐行阅读.

  • 文件大小:564 MB(591,886,626字节)
  • 文件编码:UTF-8
  • 文件包含Unicode字符.

c# text out-of-memory

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

在ASP.NET MVC中使用jQuery调用Ajax不传递参数

路线是:

routes.MapRoute(
    "Ajax", // Route name
    "BizTalk/Services/{action}", // URL with parameters
    new
    { // Parameter defaults
     controller = "BizTalk"
    }
   );
Run Code Online (Sandbox Code Playgroud)

我的控制器是:

public JsonResult AjaxTest(string s, int i, bool b)
  {
   return Json("S: " + s + "," + "I: " + i + "," + "B: " + b);
  }
Run Code Online (Sandbox Code Playgroud)

我的jQuery代码:

$(document).ready(function() {
   $("#btn_test").click(function() {
    var s = "test";
    var i = 8;
    var b = true;
    $.ajax({
     type: "POST", cache: false,
     url: "/BizTalk/Services/AjaxTest",
     data: { i: i, s: …
Run Code Online (Sandbox Code Playgroud)

parameters ajax asp.net-mvc jquery

3
推荐指数
1
解决办法
8430
查看次数