恐怕我束手无策了,找不到解决方法。我已经用尽了Google-fu的能力,现在不得不寻求帮助。恐怕我是新手,可能很简单,这是我正在学习的一个小项目。
切入正题。我将ASP.NET Core 3.1与使用终结点的MVC控制器一起使用。我想将我的区域分别添加到startup.cs中的端点路由中。我在_ViewImports中设置了TagHelpers,并且其他视图正在运行。
问题:在我的具有分页列表的图书编辑器中,链接缺少区域x <- reactive({
a<- switch(input$type,
file=
if(is.null(input$file1)) return(NULL) else
read.csv(input$file1$datapath,
header = input$header,
sep = input$sep,
quote = input$quote),
file=
if(is.null(input$file2)) return(NULL) else
read.csv(input$file2$datapath,
header = input$header,
sep = input$sep,
quote = input$quote)
,
ds=get(input$ds, "package:datasets"),
url= if(is.null(input$url1)) return(NULL) else
read.csv(url(input$url1))
)
if(input$disp == "head") {
return(head(a))
}
else {
return(a)
}
})
,如果我将Dashboard/
放入asp-area="Dashboard"
表单链接中与他们互动时,我会生成以下URL:
所以没有:
我正在将区域附加到<a></a>
。我发现了几篇文章,但是它们似乎都只能解决我不想要的{area:exists}问题。
以下是我在&area=Dashboard
下的Startup.cs,我认为这是正确的,因为我想摆脱app.UseEndpoints(endpoints =>
的模式。
area:exists
我一直在尝试使用路由做很多事情,并尝试使用HttpGet。
namespace TestProject
{
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.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public class UntrustedCertClientFactory : DefaultHttpClientFactory
{
public override HttpMessageHandler CreateMessageHandler()
{
return new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (a, b, c, d) => true
};
}
}
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
FlurlHttp.ConfigureClient("https://127.0.0.1", cli => cli.Settings.HttpClientFactory = new UntrustedCertClientFactory()); //Ignore test certs
var settingsfile = File.ReadAllText(@"settings.json");
var deserialjson = JsonConvert.DeserializeObject<SettingsJson>(settingsfile);
if (deserialjson.DatabaseProvider == DBProviderWrittenSetJson.MSSQL)
{
var connection = Configuration[@"MSSQLDBConnection"];
services.AddDbContext<TestProjectContext>
(options => options.UseSqlServer(connection,
x => x.EnableRetryOnFailure())
);
services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<TestProjectContext>();
}
if (deserialjson.DatabaseProvider == DBProviderWrittenSetJson.PostgreSQL)
{
var connection = Configuration[@"PostgreSQLConnection"];
services.AddDbContext<TestProjectContext>
(options => options.UseNpgsql(connection,
x => x.EnableRetryOnFailure())
);
services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<TestProjectContext>();
}
services.AddControllersWithViews()
.AddNewtonsoftJson();
services.AddRazorPages();
services.AddServerSideBlazor();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TestProjectContext context)
{
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
var settingsfile = File.ReadAllText(@"settings.json");
var deserialjson = JsonConvert.DeserializeObject<SettingsJson>(settingsfile);
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapRazorPages();
endpoints.MapBlazorHub();
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapAreaControllerRoute(
name: "Dashboard",
areaName: "Dashboard",
pattern: "{area=Dashboard}/{controller=Home}/{action=Index}/{id?}",
defaults: new { area = "Dashboard", controller = "Home", action = "Index" });
});
}
}
}
我将为所见内容创建一个简单的演示,以供更多使用!