- version .NET 6
- product type MVC Core
- .NET Core
Making Ajax Post Trying to hit an action method for a controller in diferent area fails with 500 error. Same code was working in ABP Boilerplate and ASP NET Core Project but not in Zero, Also it works in case the ACTION method is in same Calling Controller. So URL without area works ok.
var model = { "SectionId": @FileUploaderConsts.HR_CV, "ParentId": recordId }; $.ajax({ type: "POST", url: '@Url.Action("Async_GetPdfFile", "DocumentsAndFiles", new { area = "DocumentManagement" })', dataType: "json", data: model, success: function (pdf) { alert("OK"); }
` [Area("DocumentManagement")] [Route("DocumentManagement/[controller]/[action]")] [AllowAnonymous] public class DocumentsAndFilesController : ArchiroxControllerBase {
[HttpPost]
[DontWrapResult]
public async Task<DM_PDF_ViewModel> Async_GetPdfFile(DM_AdditionalFileInfo_ViewModel model)
{
return await _iDM_File_Handler_AppService.GetPdfBlob(model.ParentId, model.SectionId);
}
` the url:"/DocumentManagement/DocumentsAndFiles/Async_GetPdfFile" is not being hit, however if the Async_GetPdfFile is local the POST is success. The logged in user is admin which has all the permissions, and i tried decorating the DocumentsAndFiles with [AllowAnonymous] to eliminate the possibilty of permission issues, the url construction looks OK, Please see attached image.
Your help is appreciated.
3 Answer(s)
-
0
Hi,
Could you check your server side log file ? It is located under App_Data/Logs folder with Logs.txt name.
-
0
ok the issue was in a FileAppService not registering the ConfigrationFile, One Issue is Before injecting IConfigration to read from appsetting.json, I also tried injecting IConfigurationRoot this throws error, Can you please advise how to get appsetting.json values IN ASP NET ZERO , there is little to no documentation on the subject.
` private readonly IConfiguration _configuration;
public ArchiroxApplicationModule(IConfiguration configuration) { _configuration = configuration; } public override void PreInitialize() { Configuration.Authorization.Providers.Add<ArchiroxAuthorizationProvider>(); }` public method() { var key = _configuration.GetValue<string>("Azure:AccountName"); //Always NULL } //THE APPSETTING.json } "Azure": { "ConnectionStrings":"somestringt", "AccessKey": "somestring2", "AccountName": "somestring2" } }
-
0
Hi,
You can do it as shown below;
public AbpZeroTemplateWebCoreModule(IWebHostEnvironment env) { _env = env; _appConfiguration = env.GetAppConfiguration(); }
and access the configuration like this;
_appConfiguration["Azure:AccountName"]