Category "asp.net-mvc"

HttpContext.User.Identity.IsAuthenticated throws System.NullReferenceException: Object reference not set to an instance of an object

My code is simple like : [HttpGet] public ActionResult Login () { if (User.Identity.IsAuthenticated) { return RedirectToAction("Index", "Home");

CSS, Images, JS not loading in IIS

My all applications were working fine but suddenly all sites under IIS are not loading css, images, scripts. It redirect to login page. If i login it works fi

How to apply Bootstrap dropdown style to an ASP.NET MVC DropDownList?

Given is the following MVC razor code which creates a dropdown from a list: @Html.DropDownList("MyTestList", null, new { @class = "btn btn-default dropdown-to

The default XML namespace of the project must be the MSBuild XML namespace

I cloned the ASP.NET Core SignalR Repo locally, and try opening the solution from within the following environment. IDE Microsoft Visual Studio Enterprise 201

How can I pass a String as a model to a View in MVC 5?

I have an action defined like this: public ActionResult TempOutput(string model) { return View(model); } And also, I have its view define

Adding nonce value to @Scripts.Render ASP.Net MVC razor pages with NWebSec

I am trying to implement Content-Security-Policy with the NWebSec NuGet package The basic configuration level is working at this moment but trying to add nonce

Make sure that the controller has a parameterless public constructor error

I have followed this tutorial which has worked great, until I modified my DbContext to have an additional constructor. I am now having issues with the resolutio

How to check radiobutton with Enum value in Asp.net core mvc view?

I have rendered my view like below <div class="row row-margin-zero"> <label class="radio-inline margin-rightt-ten margin-leftt-five margin-top-none

Microsoft Exchange WebService Contact Email Addresses formatting

I have set up a microsoft exchange web service to allow me to send and receive data to and from my Microsoft Outlook account. I am attempting to get the saved

Telegram login widget return "bot domain invalid" in my mvc app

I use telegram login widget in MVC App , and follow steps as in post telegram-web-login-widget-setdomain-does-not-work Steps As in Post Here is how the di

The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception

I have ASP.Net MVC site. Technology Stack ASP.Net 4.6 C#.Net EF 6 MySQL -Database While I am trying to generate the database using Nuget command:- Enable-Mi

Some (official or not) upgrade Mvc3 to Mvc5 guide?

There is a (non-Microsoft) NuGet package that allows upgrading the Mvc3 to Mvc4. There is a (Microsoft) article that explains how to manually migrate from Mvc3

Set value from model in a label using html helper

I have given view model.I have to set the value of Amount(which is getting retrieved from table using linq) on a label using Html helper. public class Allocat

Only last radio button control in list being set as checked

I have a list with each element of the list containing a star rating control which allows the user to set their preference for that element. The rating control

Prevent database access outside the application

We have a MVC application running with SQL Server database. We are using windows authentication, and when we want to give user access to our site we add them i

Using CSVHelper to output stream to browser

I'm trying to use CSVHelper to generate a CSV file and send it back to a browser, so the user can select a save location and filename and save the data. The w

Form within a foreach loop not posting the model back to the controller

I've searched around and can't find an answer to my problem. I've got a View that takes accepts Foo in like so: @model IEnumerable<MyApplication.Models.Foo

How to render MVC child Action PartialView into Layout @RenderSection()?

In the layout, MVC child actions are called in . However, the the partialView results are not shown in the RenderSection("userProfile", required:false). The Wa

How to add project reference to ASP.NET Core 1.0 MVC project

I have a ASP.NET Core 1.0 MVC app in solution X and I have some common projects (.net 4.5.2 class libs) in solution Y. I want to reference the projects in solu

Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing

I had an Asp.Net core 2.2 project. Recently, I changed the version from .net core 2.2 to .net core 3.0 Preview 8. After this change I see this warning message