我收到以下错误:
Child actions are not allowed to perform redirect actions.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Child actions are not allowed to perform redirect actions.
Source Error:
Line 1: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<RenderActionViewModel>" %>
Line 2: <%Html.RenderAction(Model.ActionName, Model.ControllerName, Model.RouteValues); %>
Line 3:
The Stack trace is:
[InvalidOperationException: Child actions are not allowed …Run Code Online (Sandbox Code Playgroud) 我刚刚在我的MVC网站上安装了Hangfire包.我创建了一个Startup类
[assembly: OwinStartup(typeof(Website.Startup))]
namespace Website
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
Hangfire.ConfigureHangfire(app);
Hangfire.InitializeJobs();
}
}
}
Run Code Online (Sandbox Code Playgroud)
和一个Hangfire课程
public class Hangfire
{
public static void ConfigureHangfire(IAppBuilder app)
{
app.UseHangfire(config =>
{
config.UseSqlServerStorage("DefaultConnection");
config.UseServer();
config.UseAuthorizationFilters();
});
}
public static void InitializeJobs()
{
RecurringJob.AddOrUpdate<CurrencyRatesJob>(j => j.Execute(), "* * * * *");
}
}
Run Code Online (Sandbox Code Playgroud)
另外,我在一个单独的类库中创建了一个新工作
public class CurrencyRatesJob
{
private readonly IBudgetsRepository budgetsRepository;
public CurrencyRatesJob(IBudgetsRepository budgetsRepository)
{
this.budgetsRepository = budgetsRepository;
}
public void Execute()
{
try
{
var budgets …Run Code Online (Sandbox Code Playgroud) 我的网站上的 Automapper 有问题,我找不到解决方案。我创建了一个名为 AutoMapperProfile 的类,我想在其中放置我所有的地图
public class AutoMapperProfile: Profile
{
private readonly IConfiguration _mapper;
public AutoMapperProfile(IConfiguration mapper)
{
_mapper = mapper;
}
protected override void Configure()
{
base.Configure();
_mapper.CreateMap<SlideDTO, Slide>();
_mapper.CreateMap<Slide, SlideDTO>();
}
}
Run Code Online (Sandbox Code Playgroud)
出于 DI 目的,我使用 Ninject,因此我在 NinjectWebCommon 中添加了以下绑定:
kernel.Bind<IMappingEngine>().ToMethod(ctx => Mapper.Engine);
kernel.Bind<IConfigurationProvider>().ToMethod(x => Mapper.Engine.ConfigurationProvider);
Run Code Online (Sandbox Code Playgroud)
控制器看起来像这样:
private readonly ISlideRepository slideRepository;
private readonly IMappingEngine mappingEngine;
public HomeController(
ISlideRepository slideRepository,
IMappingEngine mappingEngine)
{
this.slideRepository = slideRepository;
this.mappingEngine = mappingEngine;
}
[HttpGet]
public ActionResult Index()
{
var model = new IndexViewModel();
var …Run Code Online (Sandbox Code Playgroud) 我创建了一个 ASP.NET MVC 网站。然后我创建了一个名为 Site.Scheduler 的类库,我想在其中放置我所有的触发器和作业。
我为测试目的创建了一个简单的工作
public class CurrencyRatesJob : IJob
{
private readonly IBudgetsRepository budgetsRepository;
public CurrencyRatesJob(IBudgetsRepository budgetsRepository)
{
this.budgetsRepository = budgetsRepository;
}
public void Execute(IJobExecutionContext context)
{
try
{
var budgets = new BudgetsDTO();
var user = new UserDTO();
budgets.Sum = 1;
budgets.Name = "Quartz";
user.Email = "email@g.com";
budgetsRepository.InsertBudget(budgets, user);
}
catch (Exception ex)
{
throw new Quartz.JobExecutionException(ex);
}
}
}
Run Code Online (Sandbox Code Playgroud)
和作业调度程序
public class CurrencyRatesJobScheduler
{
public static void GetCurrencyRates()
{
try
{
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler(); …Run Code Online (Sandbox Code Playgroud) 我的问题是:你如何检查给定的字符串是否是回文的字谜?
我在互联网上找到了Python的一些解决方案,但我不知道如何检查它.我正在考虑将strig转换为a char [],然后为每个角色获得HashCode,但是我被卡住了.
c# ×4
asp.net ×2
asp.net-mvc ×2
anagram ×1
automapper ×1
hangfire ×1
palindrome ×1
quartz.net ×1
scheduler ×1
security ×1