All Questions
Tagged with asp.net-core-mvc asp.net-core-2.0
505
questions
1
vote
0
answers
92
views
Bulk Insert data from Excel to SQL database that contains foreign key
I have an Excel file with up to 4000 rows and 10 columns of data, and I want to insert these records into the database.
Some columns are titles of another table of the database and I must find Id of ...
0
votes
1
answer
430
views
How to get Antiforgery token before sending response?
I have ASP.NET Core application which auto validates every POST request for AntiforgeryToken:
services.AddMvc(options =>
{
options.Filters.Add(new AuthorizeFilter(...
0
votes
0
answers
313
views
How to add HTML attribute without attribute name using TagBuilder?
I am building a Input tag using TagBuilder. I want to build the input tag like below
<input name="IsOkay" type="checkbox" {% if MyObject.IsOkay == true %} checked="checked&...
0
votes
0
answers
313
views
Dynamically serve all files in a certain folder only after providing password in .NET Core 2.2
I have a web app in .NET Core that serves all files in a certain folder. Now before serving the files, a password is needed. Is this code sufficient or is there a loophole in it?
using DownloadFiles....
1
vote
1
answer
1k
views
how to post data without passing it to model .Net Core
I have this in my view
<form class="d-inline-block" asp-controller="">
<div class="form-group mb-2 d-inline-block">
...
1
vote
0
answers
252
views
Session Expires after 15-20 Minutes in asp.net core 2.0. Any solution Not working
Hello Buddies I hope you all good. I am having session expiration problem. it took weeks but not solved
yet I hope I will get help from here.
services.Configure<CookiePolicyOptions>(options =>...
1
vote
1
answer
4k
views
How to logout ClaimsIdentity User when using OpenIDConnect
I have ASP.NET Core application that is using OpenIDConnect authentication. In OnTokenValidated event i check if Authenticated user exists in the my application's database, and if not then i am ...
0
votes
1
answer
475
views
How to get app insights working on an azure webjob with .net core 2.x?
I have a webjob with .net core 2.1
I have an instrumentation key on the appsettings.json.
and I have this on the method ConfigureServices in program.cs
services.AddApplicationInsightsTelemetry(...
6
votes
2
answers
1k
views
Pass sub object to partial view from views with different models, have it bind when form is posted
I have an ASP.net MVC Core 2 (can upgrade to 3 if required) web app.
There are several different classes, landlord, tenant, contractor - they each have an address object, and other different ...
3
votes
1
answer
3k
views
How to read Windows environment variables on dotnet core?
I am building a Web API using dotnet core 3.1 and now I got into the need to store a kind of sensitive information on a Windows Environment variable which I already did. Let's call it MY_WIN_VAL_X.
...
0
votes
2
answers
1k
views
Where does this C# HttpContext context in Startup.cs come from?
So I came across this RazorPages sample code
using Microsoft.AspNetCore.Mvc;
// This method gets called by the runtime. Use this method to add services to the container.
public void ...
0
votes
1
answer
164
views
I am unable to store data into database using Entity Framework Core and Ajax
I have a problem with my code. The problem is I am not getting post data by parameter using ajax.
Can anyone fix this? The code is shown below.
This is Javascript Ajax code where I am sending data ...
0
votes
1
answer
1k
views
How to post List of Dictionary
I have a client ( in this case POSTMAN) that is posting collection of object. The properties of the object are not known in advance so I cannot use concrete C# model.
So I am using Dictionary<...
2
votes
1
answer
2k
views
Relative Path for Sqlite database via DbContextOptionsBuilder.UseSqlite?
I have a .Net Core 2.2 project where the back-end needs to open a DbContext to a Sqlite database.
I need something like:
optionsBuilder.UseSqlite(@"Data Source=Data\Database.db");
However the ...
0
votes
0
answers
79
views
reading 500 MB xlsx file with OpenXML in aspnet core 2.1 is giving stream is too large
Reading 500 MB xlsx file with OpenXML in aspnet core 2.1 is giving stream is too large.
is it any other way to read 1 gb excl file in openXML
below is my code
using (Stream stream = new FileStream(...
0
votes
1
answer
180
views
Asp.net core 2.0 mvc application get client ip address with load balancer option
I am unable to get client IP address using .net core 2.0 application.
I used the below code in startup.cs file.
I used the below code in homecontriller.cs file.
I am getting remoteIpAddress is 1.0....
1
vote
1
answer
378
views
Call script from Server side in asp.net mvc core 3.0
I'm trying to open bootstrap modal from server side in asp.net mvc core 3.0 but unable open getting error
ViewBag.RegisterStartupScript(this, this.GetType(), "$('#modalRegisterForm').modal('show')", ...
0
votes
1
answer
3k
views
Post data with files using ASP.NET Core MVC to api (ASP.NET Core Web API)
I need to post data with files but I face this problem - all data is null.
It works when I use postman:
My post function in ASP.NET Core Web API:
public async Task<ActionResult<Category&...
1
vote
1
answer
592
views
How to implement Entity atribute value model (EAV) using EF Core and ASP.NET Core?
Let's say I have one entity USER and added some fix properties during the application development. Then after the application deployment if some user wants to add more custom field based on text-field,...
0
votes
3
answers
164
views
Why are my single select lists converting to multi select lists on model binding?
I'm trying to bind multiple single select lists to one list of strings in my view model I have the property: public List<string> Items {get; set;} and in my view I have 3 select lists with ...
6
votes
4
answers
6k
views
.net core , how to handle route with extra leading slash
I need to handle an incoming request which is of the form:
//ohif/study/1.1/series
Note the exta slash at the front
My controller signature is:
[Route("ohif/study/{studyUid}/series")]
[HttpGet]
...
2
votes
2
answers
824
views
Loading multiple viewcomponents in an ASP.net core 2.2 cshtml
I'm new to Asp.Net core but i have worked with Asp.net MVC 5.I have a problem with loading multiple view components inside a view.(using Asp.net core 2.2)
I have page which loads a viewcomponent ...
1
vote
1
answer
448
views
PagedList pager doesn't increment page number or routes to the specified controller
I'm having problems with X.PagedList package. I'm using.net core mvc 2.2 for the project. Whatever I do the PagedListPager doesn't seem to work. It doesn't increment the page number and can't change ...
0
votes
1
answer
640
views
Deciding to use Authorization or not on a per-request basis in Asp.net Core
I'm developing an ASP.net core MVC 2.2 app and at the moment I'm using the classic [Authorize] and [AllowAnonymous] attributes on my controller actions to decide whether a certain action can be ...
0
votes
0
answers
3k
views
Error: The remote server returned an error: (500) Invalid WSDL access, no SOAP request expected C#
I am consuming SOAP web service in my .net core application. I am getting below error in c# code
"The remote server returned an error: (500) Invalid WSDL access, no SOAP request expected."
...
0
votes
0
answers
98
views
ASP.NET Core API with localized strings
We have an ASP.NET Core API. There are no views as again this is a simple API. We have strings in resource files(by culture) and we want each user to get the correct resource (in each API request we ...
0
votes
1
answer
520
views
Passing Controller Action output as SupplyData in UseSpaPrerendering of .Net Core
In .Net Core application, I have below code in Configure method of Startup.cs file.
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
spa....
1
vote
1
answer
43
views
How to resolve my problem with upload file [closed]
How can I upload my Image in asp.net core 2 without saved to database and after will show it in other View? Help, please.
0
votes
1
answer
375
views
Different projects with controllers and views
I should write a big software for a company. This company has many different departments, but each department needs the same base-functions and also some specific department features. Therefore i ...
8
votes
1
answer
2k
views
Cache-Control warning getting logged when add ResponseCache attribute
I have ASP.NET Core 2.2 application. I have set no-store=true on all controllers for the cases when the user clicks the browser's back button
[ResponseCache(NoStore = true)]
public class MyController:...
2
votes
1
answer
801
views
session being null when redirect to query string url in .net core
I'm setting url with query string when anyone hit such page which is only access after login. I set that controller name as query string and redirect to login page. everything working good till here. ...
2
votes
2
answers
7k
views
How do I run/trigger service in startup.cs?
I have a service which grabs the token and save in cache, I added service like below, but it's not running when the app starts what do I need to do to trigger this service on startup
public void ...
1
vote
0
answers
327
views
Extending ClaimsIdentity?
I'm trying to customize ClaimsIdentity.
The reason being that I don't want to use cookies to hold all the claims because in the context of my application, I have many (hundreds) Projects a user could ...
0
votes
1
answer
1k
views
How to make IMemoryCache available in all controllers?
I have followed this tutorial https://learn.microsoft.com/en-us/aspnet/core/performance/caching/memory?view=aspnetcore-2.2
It is using Dependency Injection to make IMemoryCache available in specific ...
1
vote
1
answer
3k
views
What is alternative of "TransparentNetworkIPResolution" in ASP.NET CORE
I have used "TransparentNetworkIPResolution" this keyword in ASP.NET MVC
in SQL Connection string.
My code as below
<add name="LocalString" connectionString="Data Source=Server;Initial Catalog=...
0
votes
1
answer
339
views
Linq GroupBy expression raises AnonymousType exception
I have a query that returns an IEnumerable that I use to display a table of values.
I would like to group the tables (using a <H3/> element) by the model's DateTime field (StartTime).
I ...
0
votes
0
answers
267
views
ASP.NET Core: [Policy based Authorization] No authenticationScheme was specified, and there was no DefaultChallengeScheme found
I use policy-based authentication to provide access based on menu rights to logged in user. If the menu has access then I call context.Succeed(requirement); but on error (unauthorized menu access), I ...
0
votes
1
answer
53
views
Make JSON deserialiser distinguish between a class and a subclass of that class
In an asp.net core mvc application I'm working on, I use sessions to keep track of a List of instances of a model I made called "Rule".
Now, you can't save objects other than strings and integers in ...
2
votes
1
answer
341
views
MVC Change Landing Page is not working: Options.Conventions.AddPageRoute(
I tried changing the landing page of my web page Mvc application using this command. However it is still redirecting me to regular index, not Products/Index. How would I resolve this?
public void ...
3
votes
1
answer
936
views
Change MVC Home Landing Page: No service for type 'Microsoft.Extensions.DependencyInjection.IServiceCollection' has been registered
I tried changing the landing page of my web page mvc application using this command.
I received this error below. How would I resolve it?
public void Configure(IServiceCollection services, ...
0
votes
2
answers
621
views
How to have two different types of users for WebAPI and MVC .netcore 2.0
I'm creating an asp.net core 2.0 app (with EFCore an Identity), which has:
website (MVC) where people can register and buy different plans
(with different prices etc). So, these users must confirm e-...
1
vote
1
answer
228
views
Url.Action is wrong with Knockout + Asp.Net MVC Core 2.2
I am trying to generate a table containing a link for each row with knockout and Asp.Net Core 2.2. Actually I want the whole row to be clickable later, for this example I added it as a table field ...
0
votes
0
answers
309
views
ASP.NET Core MVC view: Copying View and Repasting Code, Identifier Expected error received
I am trying to create a simple ASP.NET Core MVC app to display files in folder on webpage. I am getting an error
Error: identifier expected in first line for view
How would I resolve this? It ...
1
vote
1
answer
290
views
How to inspect asp.net core methods?
I created a new ASP.NET Core MVC application with individual user accounts authentication. I would like to see how they implemented some methods. I suppose I can do it since ASP.NET Core is open ...
2
votes
0
answers
2k
views
Net Core: 'RouteCollection' does not contain a definition for 'IgnoreRoute'
I am migrating a project from .Net 4.6.2 to .Net Core 2.0. What is the replacement for IgnoreRoute in .Net Core?
I'm receiving the error below:
Code:
public static void RegisterRoutes(...
1
vote
1
answer
3k
views
Creating user with same UserName and Email always return invalid user name error
Tried to create a user in identity tables using .net core. But it always return an error invalid UserName.
var user = new ApplicationUser();
user.UserName = "[email protected]";
...
1
vote
1
answer
2k
views
Validation error message not displayed in Asp.Net Core 2 MVC partial view
I have an index page with a list of "workbooks" titles and for each workbook, there is a "share" button. When pressing the button a bootstrap model (i.e. dialog) appears which displays the title of ...
1
vote
1
answer
4k
views
How to Edit Enumerable or List View in MVC Net Core
How do I create a Edit View for a List?
The following is a sample view and model for a single item, which works correctly.
Next question is, I have a list of items I want to edit. How would I conduct ...
1
vote
3
answers
3k
views
How do you change the default AntiForgeryToken identifier in asp.net core mvc?
Im trying to use AWS Cognito for my auth in a .Net Core MVC-app.
The login works fine, but none of my forms in the views work, they all give an error about my claims not containing "Name"-Claim.
I ...
0
votes
1
answer
2k
views
How to use WebGrid in ASP.NET Core 2.0
I am trying to use WebGrid in ASP.NET Core (installed package NonFactors.Grid.Mvc6 followed instructions from link
@(Html.Grid(Model).Build(columns =>
{
...