[英]ASP.NET Core 3.1 identity persist cookie authentication after web deploy publish to remote IIS still fails
[英]ASP.NET Core api project 3.1 publish on IIS
I am trying to deploy my ASP.NET Core API project in my pc local IIS Server using Web Deploy feature in Visual Studio 2019.
我可以从本地 IIS 服务器成功调用所有 api。
当我发布到远程服务器并调用 api 时,它显示HTTP 错误 500.30 - ANCM In-Process Start Failure错误。
在 ProjectController.cs
[HttpGet]
[Route("api/Testing")]
public async Task<IActionResult> GetUserList()
{
try
{
List<PatientName> lstPAtientName = new List<PatientName>();
lstPAtientName.Add(new PatientName() { PName = "ABC" });
lstPAtientName.Add(new PatientName() { PName = "XYZ" });
var dict = new Dictionary<string, object>();
dict.Add("PatientList", lstPAtientName);
return Ok(dict);
}
catch (Exception ex)
{
throw ex;
}
}
在 Startup.cs 中
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers().AddNewtonsoftJson();
//Configure CORS also to make this API enable for other application
services.AddCors(option => option.AddPolicy("MyBlogPolicy", builder =>
{
builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
}));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
services.AddScoped<ProjectRepository>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
//Configure CORS also to make this API enable for other application
app.UseCors("MyBlogPolicy");
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
我已经设置了 stdoutLogEnabled="true" 。 网站/日志显示如下。 **
Unhandled exception. System.FormatException: Could not parse the JSON file.
---> System.Text.Json.JsonReaderException: 'S' is an invalid escapable character within a JSON string. The string should be correctly escaped. LineNumber: 21 | BytePositionInLine: 61.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.ConsumeStringAndValidate(ReadOnlySpan`1 data, Int32 idx)
at System.Text.Json.Utf8JsonReader.ConsumeString()
at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.JsonDocument.Parse(ReadOnlySpan`1 utf8JsonSpan, Utf8JsonReader reader, MetadataDb& database, StackRowStack& stack)
at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory`1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedBytes)
at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory`1 json, JsonDocumentOptions options)
at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.ParseStream(Stream input)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream)
--- End of inner exception stack trace ---
at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(ExceptionDispatchInfo info)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load()
at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at Website.Program.Main(String[] args) in E:Website\Program.cs:line 12
**
有没有加
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
在您的.csproj
文件中?
在此处查看资源: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-3.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.