I have Project Of .net Core. I have document and document to some changes after download new Document.
Like: simple "Hi ##one##,"
Output: "Hi ABC"
Thanks In Advance.
I have Project Of .net Core. I have document and document to some changes after download new Document.
Like: simple "Hi ##one##,"
Output: "Hi ABC"
Thanks In Advance.
hi
i was building web application that connect to Database and this is my code
[HttpPost] public IActionResult Index(int AccountID,DateTime StartDate, DateTime EndDate,string ReportNO) { var UserName = User.Identity.Name; SqlConnection connection = new SqlConnection(my connection string ); connection.Open(); SqlCommand command = new SqlCommand("SELECT * FROM [dbo].[tblReports]", connection); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { reader.read(); } return view(); }
how i can export SqlDataReader in excel sheet file?
I started with and <a href="/PageB?id=@Html.DisplayFor(modelItem => item.BlFileName)"
And I can read the querystring
string id= "id";
IQueryCollection foo = Request.Query;
if (foo.ContainsKey(id))
{
value = foo[id].ToString(); // great value given
...
But if I use <a asp-page="./PageB" asp-route-id="@Html.Displ..
string value = foo["id"].ToString();
value = Microsoft.AspNetCore.Mvc.ViewFeatures.StringHtmlContent
What happened to the query value/route value & how to get it ??
Thanks
I have a number of entities that are keyed by integer primary keys and relations between them, ie foreign keys that are integers.
I am now building an in-memory caching mechanism, basically putting records in dictionaries with the primary key as key for the dictionaries.
I use the navigation entries in the model metadata of the DbContext and through that I have found out how to call the GetGetter methods to get the actual navigation properties, but I haven't been able to really figure out how to get the actual foreign key
value, i.e. in my case the integer pointing to a related record.
I kind of figured out that I probably will find it through:
navigation.ForeignKey.DependentToPrincipal
But then I am kind of stuck...
Is there anyone with detailed understanding of the internals of EF Core that can give me a tip on how to do this?
How can I for the selected navigation get the actual value of the foreign key?
Hi,
in my project i use two database at same time in hosted service
i have a method that check the table faq if faq_id exists update it or its not exists add to table.
i want the new record in first database add to second database but is exists update them in second database from first database,
but when update its how this error
METHOD
public void ChangeFAQ(ApplicationDbContext AppDb,MiddleDbContext MidDb) { var list = AppDb.FAQ_tb.ToList(); var list_middle = MidDb.FAQ_tb.ToList(); foreach (var item in list) { if (!list_middle.Any(x => x.FAQ_ID == item.FAQ_ID)) { item.FAQ_ID = 0; MidDb.FAQ_tb.Add(item); } else { MidDb.FAQ_tb.Update(item); } } MidDb.SaveChanges(); }
Service
private void DoWork(object state) { using (var scope = _scopeFactory.CreateScope()) { var main_context = scope.ServiceProvider.GetService<ApplicationDbContext>(); var middle_context = scope.ServiceProvider.GetService<MiddleDbContext>(); ChangeFAQ(main_context,middle_context); } }
ERROR
The instance of entity type 'FAQ' cannot be tracked because another instance with the key value '{FAQ ID: 1}' is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached.'
Hi, I have this error and have been looking it up on the internet.
Unfortunately i am not able to fix this problem and tried all kind of things that i found.
Here is the error:
An unhandled exception occurred while processing the request. InvalidOperationException: No service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]' has been registered. Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) Stack Query Cookies Headers InvalidOperationException: No service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]' has been registered. Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) Microsoft.AspNetCore.Mvc.Razor.Internal.RazorPagePropertyActivator+<>c__DisplayClass8_0.<CreateActivateInfo>b__1(ViewContext context) Microsoft.Extensions.Internal.PropertyActivator<TContext>.Activate(object instance, TContext context) Microsoft.AspNetCore.Mvc.Razor.Internal.RazorPagePropertyActivator.Activate(object page, ViewContext context) Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator.Activate(IRazorPage page, ViewContext context) Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context) Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts) Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter) Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context) Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode) Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, string contentType, Nullable<int> statusCode) Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result) Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsync<TFilter, TFilterAsync>() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultFilters() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync() Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; using Website.Web.Data; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using System; using Microsoft.AspNetCore.Mvc; using Website.Web.Models; namespace Website.Web { 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) { //Coookiesssss services.Configure<CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); //Set database Connection from application json file services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer( Configuration.GetConnectionString("DefaultConnection"))); //add identity services.AddIdentity<ApplicationUser, IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); //configure identity options services.Configure<IdentityOptions>(options => { // Password settings. options.Password.RequireDigit = true; options.Password.RequireLowercase = true; options.Password.RequireNonAlphanumeric = true; options.Password.RequireUppercase = true; options.Password.RequiredLength = 6; options.Password.RequiredUniqueChars = 1; // Lockout settings. options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5); options.Lockout.MaxFailedAccessAttempts = 5; options.Lockout.AllowedForNewUsers = true; // User settings. options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+"; options.User.RequireUniqueEmail = false; }); //configure cookiesss services.ConfigureApplicationCookie(options => { // Cookie settings options.Cookie.HttpOnly = true; options.ExpireTimeSpan = TimeSpan.FromMinutes(5); options.LoginPath = "/Identity/Account/Login"; options.AccessDeniedPath = "/Identity/Account/AccessDenied"; options.SlidingExpiration = true; }); //add mvc 2.2 services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); //adding autorization policy's services.AddAuthorization(options => { options.AddPolicy("RequireAdminRole", policy => policy.RequireRole("Admin")); }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseMvc(); app.UseMvc(routes => { routes.MapRoute( name: "areas", template: "{area:exists}/{controller=Home}/{action=Index}/{id?}" ); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); //Seed atabase with new roles Seed.CreateRoles(app.ApplicationServices,Configuration).Wait(); } } }
using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using System; using System.Threading.Tasks; using Website.Web.Models; namespace Website.Web.Data { public static class Seed { public static async Task CreateRoles(IServiceProvider serviceProvider, IConfiguration Configuration) { var scopeFactory = serviceProvider.GetRequiredService<IServiceScopeFactory>(); var scope = scopeFactory.CreateScope(); //adding customs roles var RoleManager = scope.ServiceProvider.GetRequiredService<RoleManager<IdentityRole>>(); string[] roleNames = { "Admin", "Manager", "Member" }; IdentityResult roleResult; foreach (var roleName in roleNames) { // creating the roles and seeding them to the database var roleExist = await RoleManager.RoleExistsAsync(roleName); if (!roleExist) { roleResult = await RoleManager.CreateAsync(new IdentityRole(roleName)); } } // creating a super user who could maintain the web app var poweruser = new ApplicationUser { UserName = Configuration.GetSection("AppSettings")["UserEmail"], Email = Configuration.GetSection("AppSettings")["UserEmail"] }; //var UserManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>(); //string userPassword = Configuration.GetSection("AppSettings")["UserPassword"]; //var user = await UserManager.FindByEmailAsync(Configuration.GetSection("AppSettings")["UserEmail"]); //if (user == null) //{ // var createPowerUser = await UserManager.CreateAsync(poweruser, userPassword); // if (createPowerUser.Succeeded) // { // // here we assign the new user to the "Admin" role // await UserManager.AddToRoleAsync(poweruser, "Admin"); // } //} } } }
using System; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Website.Web.Data; namespace Website.Web { public class Program { public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var serviceProvider = services.GetRequiredService<IServiceProvider>(); var configuration = services.GetRequiredService<IConfiguration>(); Seed.CreateRoles(serviceProvider, configuration).Wait(); } catch (Exception exception) { var logger = services.GetRequiredService<ILogger<Program>>(); logger.LogError(exception, "An error occurred while creating roles"); } } host.Run(); } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .Build(); } }
using System; using System.Collections.Generic; using System.Text; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Website.Web.Models; namespace Website.Web.Data { public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); // Customize the ASP.NET Identity model and override the defaults if needed. // For example, you can rename the ASP.NET Identity table names and more. // Add your customizations after calling base.OnModelCreating(builder); } } }
Thanks in advance!
Hi,
I try to understand how to use enums to populate a dropdown in asp.net core.
I have a page cshtml file:
@page @model RazorPlaying.Pages.RazorTest3Model @{ ViewData["Title"] = "RazorTest3"; }<h1>RazorTest3</h1><br /><select asp-for="weekDag" asp-items="Html.GetEnumSelectList<DayOfWeek>()"></select><select asp-for="Maand" asp-items="Html.GetEnumSelectList<MonthEnum>()"></sel
And a cshtml.cs file
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.Rendering; namespace RazorPlaying.Pages { public class RazorTest3Model : PageModel { public DayOfWeek weekDag { get; set; } public enum MonthEnum {Januari,Februari,Maart,April,Mei,Juni,Juli,Augustus,September,Oktober,November,December} public MonthEnum Maand { get; set; } public void OnGet() { } } }
The first line to show the weekdays works fine with the predifined DayOfWeek enum.
But when I create my own Enum MonthEnum I get a fault in the cshtml that I am missing a using directive or assembly reference.
I have tryed to change it to Model.MonthEnum but without positve result.
What am I doing wrong?
This must be easy. I believe I have set up at least logging to be directed to the console by way of the application.Development.json
Questions :
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
},
"Console": {
"IncludeScopes": true
}
}
}
Inside the index.cshtml.cs I have ...
public ILogger<IndexModel> _logger;
public IndexModel(IConfiguration configuration,ILogger<IndexModel> logger) //,)
{
_configuration = configuration;
_logger = logger;
}
public void OnGet()
{
_logger.LogTrace("where is my logger output ?"); // where displayed ?
_logger.Log(LogLevel.Information, "Hey Logger this is information", null);
At the Output Window
IPV2.Pages.IndexModel:Information: Hey Logger this is information
Thanks !
Problem
How to add optional parameter to view component and return not exist in case of view not have result ?
I have view component return list of data based on table name ReferenceFile
what i need is to modify to accept FieldName parameter as optional may be used or may be not used
and in case of no result on view return Text message not exist
How to do that please ?
public class GetReferenceViewComponent : ViewComponent { private readonly TabDbContext _context; public GetReferenceViewComponent(TabDbContext context) { _context = context; } public async Task<IViewComponentResult> InvokeAsync(string TableName) { var result = _context.ReferenceFiles.Where(r => r.TableName == TableName).ToList(); ViewBag.GetReference = result; return View(); } on view component view @foreach (var itemes in ViewBag.GetReference) {<ul><li> @itemes.FieldName </li></ul> } }
what i need actually is to modify function below on view component invokeasync on getrefernce.cs and Default.cshtml
public async Task<IViewComponentResult> InvokeAsync(string TableName,optinal fieldname) { object result; if (!string.IsNullOrEmpty(FieldName)) {
// return fieldname only in case of condition occured result = _context.ReferenceFiles.Where(r => r.TableName == TableName && r.FieldName == FieldName).FirstOrDefault(); } else { result = _context.ReferenceFiles.Where(r => r.TableName == TableName).ToList(); } ViewBag.GetReference = result.ToString(); return View(); } and on view of view component Defualt.cshtml how to return not exist in case of view is empty and if i use field name as optional parameter how to modify function
pseudo code if(fieldname have value)
ViewBag.GetReference
else
@foreach (var itemes in ViewBag.GetReference) {<ul><li> @itemes.FieldName </li></ul> }
Result in case no field name is
meaning calling is
@await Component.InvokeAsync("GetReference", new { TableName = "Employees" })
result will be
code TableName FieldName 1 Employees EmployeeId 2 Employees BranchCode
and in case of no result returned return not exist
in case of field name exist as argument
meaning call as
@await Component.InvokeAsync("GetReference", new { TableName = "Employees",FieldName="EmployeeId" })
result returned is
EmployeeId
and in case of condition return null view will show Not exist
meaning it will return one result only for field Name
Problem
How to bind sales header Model to collection of sales Footer on SalesOrder controller using asp.net core 2.1 ?
I work on project have Sales Order form this form contain to :
salesHeader model
salesFooter model
so that i already have model Sales Header have navigation property to Sales Footer as following
SalesHeader Model public int SalesOrderNo { get; set; } public int SalesYear { get; set; } public ICollection<SalesFooter> SalesFooters { get; set; } SalesFooter Model public int SalesOrderNo { get; set; } public int Quantity { get; set; } public int UnitPrice { get; set; }
How to get collection of sales footer on :
on Edit action of sales Order controller how to get collection of sales footer ?
on Edit view(get) sales Order controller how to get collection of sales footer ?
What I have tried:
Repository
public T GetById(int Id) { return dbSet.Find(Id); } public class SalesOrderController : Controller { private readonly IrepositoryTab<SalesHeader> _repositoryHeader; public SalesOrderController(IrepositoryTab<SalesHeader> SalesHeader, IrepositoryTab<SalesFooter> SalesFooter) { this._repositoryHeader = SalesHeader; this._repositoryFooter = SalesFooter; } //get //Edit Action of sales Order Controller public IActionResult Edit(int? id) { var SalesHeader = _repositoryHeader.GetById(id); //How to bind with sales footer return View(); } on Edit view of Sales Order Controller <div class="form-group"><label asp-for="SalesOrderNo" class="control-label"></label><input asp-for="SalesOrderNo" class="form-control" /><span asp-validation-for="SalesOrderNo" class="text-danger"></span></div><div class="form-group"><label asp-for="SalesYear" class="control-label"></label><input asp-for="SalesYear" class="form-control" /><span asp-validation-for="SalesYear" class="text-danger"></span></div> //How to bind Sales Header with Sales Footer
on view of sales Header
<div class="post-text" itemprop="text">
Hi everyone!
I have a question to ask you.
I'm trying to figure out how to structure an ecommerce site containing 2 sections: an administrative part and a visible part to the public (the part with the catalog, the cart, and all the pages of the site).
I would like to use the "Areas". The question is this, can the administration and site part be inserted into the Areas, as in the example below? Or should only the administrative part be included in the areas?
In case both the administrative part and the site visible to the public must be placed in the areas, the "Pages" folder in the root must be deleted, right?
As a programming language I use ASP.net Core 2.2 (C #) and when I can not use MVC.
I thought of a structure like this:
-Web- wwwroot-Areas--Admin---Pages-----Products-----Categories-----....---WebSite----Pages-----Home-----Products-----....-Pages(?)
Thanks in advance
After creating the site in IIS manager and then when I try to brows the site the following error is coming.
Config Error | Cannot read configuration file due to insufficient permissions |
---|---|
Config File | \\?\C:\MyApp\web.config |
But When I copy all the files from the folder C:\MyApp in to the folder c:\inetpub\wwwroot, it is working fine. So please can you the reason for not working from the folder c:\MyApp. The folder has full permission to everyone. How can I fix the error
Hi
I am first time publishing the asp.net core program from the server and to give the access the application from the server to other system . Please can you give me a simple steps how to do that ? it would be very appreciated
I am upgrading a set of API's to Core 2.2 and have hit a wall. I am able to GET, but have not been able to get POST to function. Ajax return "Network Error". I have tried several combinations without success. Is there Security setting on the server that needs to be made? Frankly, I'm stumped and would appreciate some insight.
using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using Microsoft.AspNetCore.Mvc; namespace zpmAPI.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class LookupsController : ControllerBase { private zBestContext db = new zBestContext(); // GET api/values [HttpGet] public string sayHello() { return "hello"; } [HttpPost] //[Route("api/Lookups/LocationSearch")] public JsonResult LocationSearch(GeneralSearch g) { return new JsonResult( "hello from LocationSearch"); }
var result = "";$.ajax({ url: "https://......./api/lookups/LocationSearch", type: "POST", data: JSON.stringify(g), async: false, dataType: "json", contentType: 'application/json; charset=utf-8', success: function (data) { result = data; }, done: function (data) { result = data; }, fail: function (data) { result = data; }, error: function (jqXHR, textStatus, errorThrown) { alert('request failed :' + errorThrown); } });
Problem
How to display data for label from database on view and when input type is hidden not display data for this control or property from database ?
1- suppose I have model Employee as following
public class Employee { [key] public int EmployeeId { get; set; } public string EmployeeName { get; set; } }
2- i create reference file table and his model on project and this data on table referencefile
code TableName FieldName 1 Employees EmployeeId 2 Employees EmployeeName
when call method
@await Component.InvokeAsync("GetReference", new { TableName = "Employees" })
it show all data from reference file table success but if input type is hidden it show also data
<input type="hidden" asp-for="EmployeeId" />
in case of EmployeeId is hidden must not show EmployeeId meaning result must show
EmployeeName only
I have view component return list of data based on table name Reference File
what i need when control or property is hidden on view call function invokeasync show data not hidden on view and exist on database
How to do that please ?
pseudo code
if(field exist on reference file table && is not hidden on view ui
show it as label text
else
not display it
Code Details of view component
publicclassGetReferenceViewComponent:ViewComponent{privatereadonlyTabDbContext _context;publicGetReferenceViewComponent(TabDbContext context){ _context = context;}public async Task<IViewComponentResult>InvokeAsync(stringTableName){var result = _context.ReferenceFiles.Where(r => r.TableName==TableName).ToList();ViewBag.GetReference= result;returnView();} on view component view shared/getreference/Default.cshtml
@foreach(var itemes inViewBag.GetReference){<ul><li>@itemes.FieldName</li></ul>}}
I am really new to working with all of these different technologies so pardon me if I am missing some knowledge. In any event, I have a bit of ASP.NET MVC architecture under my belt but I have yet to really grasp the framework, tooling, or what the scaffolding
of any given ASP-type web application is doing.
tl;dr;
At the moment, I am working on hosting an ASP.NET CORE (3) web application with Azure and I have setup a plan for the App Service. The project is very simplistic and I just want to get it to run from Azure so it can field requests.The problem, is that it builds fine on my machine but when I publish it to Azure I am met with an HTTP Error 500.0 denoting that I am probably missing one of these requirements:
I think the issue boils down to that I am not doing something with IIS properly either on my local machine or in the cloud.
I will change the logging level of the application as suggested in error message I am getting when I hit the web page AND I have configured a service for Application Insights on Azure so hopefully that will help my case. I have tried a number of StackOverflow
suggestions regarding web configs and such but those just regenerate on build.
Any help would be so, so, greatly appreciated as this is a portfolio piece for me and I spent a fair amount of time working on it - I think I may have just missed something basic. Thank you.
Problem
I work on asp.net core 2.1 project with sql server 2014
This project is mvc controller not web api .
We decide to make client side with angular 7 so that i will have two project
Project have angular client side
Another project is asp.net core mvc or web api server side .
So that my question
Are my project mvc controller must be web api to connect to angular ?
if must convert mvc project controller to web api
How to change it to web api project ?
Problem
How to get text of label from database dynamically vertically ?
so that when user or change text no need to change any thing on interface or ui code for label
so that i get text from reference file and it working good but i need to make it work vertically as
a
b
c
not a b c
so that what i try to do is
public class GetReferenceViewComponent : ViewComponent { private readonly TabDbContext _context; public GetReferenceViewComponent(TabDbContext context) { _context = context; } public async Task<IViewComponentResult> InvokeAsync(string TableName) { var result = _context.ReferenceFiles.Where(r => r.TableName == TableName).ToList(); ViewBag.GetReference = result; return View(); } } and under shared/Components/GetReference/Default.cshtml I put following code to get text based on fieldname of reference file table
@foreach (var itemes in ViewBag.GetReference) {<thead> @itemes.FieldName</thead>
and on index view I call as following :
@await Component.InvokeAsync("GetReference", new { TableName = "Employees" }) }
SampleData Code TableName FieldName 1 Employees EmployeeId 2 Employees BranchCode
code above work on default index view good
but when i go to create page i need it vertically it not work
as
EmployeeId textboxinput
BranchCode textboxinput
<div class="row"><div class="col-md-4"><form asp-action="Create"><div asp-validation-summary="ModelOnly" class="text-danger"></div><div class="form-group"><label asp-for="EmployeeId" class="control-label"></label><input asp-for="EmployeeId" class="form-control" /><span asp-validation-for="EmployeeId" class="text-danger"></span></div><div class="form-group"><label asp-for="BranchCode" class="control-label"></label><input asp-for="BranchCode" class="form-control" /><span asp-validation-for="BranchCode" class="text-danger"></span></div></div></div>
public class ReferenceFile { public int Code { get; set; } public string TableName { get; set; } public string FieldName { get; set; } }
Hi all,
I wonder if there is any Opensource and free administration panel for webapplications. The best approach that I've found was the CoreUI that have a free version of their product. Therefore I wonder if there is out there any similar approach.
Cheers,
HI , i want create a i18n web site, and want to create specified Url ex: site.com/fa-IR/... site.com/en-Us/ ... site.com/en-GB/... and ....
i have no problem with cookieRequestCultureProvide but the provider doesn't create a url segment so i tred use RouteDataRequestCultureProvider
my startUp
public void ConfigureServices(IServiceCollection services) { //services // .AddMvc() // .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix) // .AddDataAnnotationsLocalization(); //services.AddLocalization(o => //{ // o.ResourcesPath = "Resources"; //}); services.AddMvc() .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix, option => { option.ResourcesPath = "Resources";}).AddDataAnnotationsLocalization().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.Configure<RequestLocalizationOptions>( opts => { var supportedCultures = new List<CultureInfo> { new CultureInfo("fa-IR"), new CultureInfo("fa-AF"), new CultureInfo("en-GB"), new CultureInfo("en-US"), new CultureInfo("en"), new CultureInfo("fr-FR"), new CultureInfo("fr"), }; opts.DefaultRequestCulture = new RequestCulture(culture: "fa-IR", uiCulture: "fa-IR"); // Formatting numbers, dates, etc. opts.SupportedCultures = supportedCultures; // UI strings that we have localized. opts.SupportedUICultures = supportedCultures; opts.RequestCultureProviders.Clear(); opts.RequestCultureProviders.Insert(0, new RouteDataRequestCultureProvider()); opts.RequestCultureProviders.Insert(1, new CookieRequestCultureProvider()); opts.RequestCultureProviders.Insert(2, new AcceptLanguageHeaderRequestCultureProvider()); opts.RequestCultureProviders.Insert(3, new QueryStringRequestCultureProvider()); services.AddSingleton(opts); }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); var options = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>(); app.UseRouter(routes => { routes.MapMiddlewareRoute("{culture=fa-IR}/{*mvcRoute}", subApp => { subApp.UseRequestLocalization(options.Value); subApp.UseMvc(mvcRoutes => { mvcRoutes.MapRoute( name: "default", template: "{culture=fa-IR}/{controller=Home}/{action=Index}/{id?}"); }); }); }); }
always i can use opts.RequestCultureProviders.Insert(0, new RouteDataRequestCultureProvider()); , it is works but i must set manually {culture=fa-IR} segment in url.
my question is i can use CookieRequestCultureProvider and RouteDataRequestCultureProvider together ? if i change cookie value automatic change url and conversely.
or solution for set automatically change {culture=fa-IR} segment instead of set manually ?