In MVC, how do I return a string result?

In my AJAX call, I want to return a string value back to the calling page. Should I use ActionResult or just return a string?

Putting HTML inside Html.ActionLink(), plus No Link Text?

I have two questions: I'm wondering how I can display no link text when using Html.ActionLink() in an MVC view (actually, this is Site.Master). There is not an overloaded version that does not...

How to download xml file in asp.net using C#

I am using an web application asp.net with mvc3. I am new to mvc3. I am having a download button on my webpage. when i am going to click the download button ,I want to able to open that XML...

How to validate the phone no?

I'm using MVC and I want to validate the phone No I wrote this class: public class StduentValidator : AbstractValidator<graduandModel> { public StduentValidator(ILocalizationService...

401 Unauthorized: Access is denied due to invalid credentials

I am using IIS Express to deploy MVC4 application. This website runs perfectly on same computer. But in Lan it gives me error 401. <authentication mode="Forms"> <forms loginUrl="~/"...

How to include custom folders when publishing a MVC application?

I have an "Uploads" folder with logos within in. I would like the VS2012 one-click publish to include this folder. Currently it is not. How can I achieve this?

Ambiguous reference to ViewModel in MVC project

I have a MVC project .NET 4.5, using VS 2013 When I start debugging the project, I get the following error on my Viewmodel: Ambiguous reference: ...

How to prevent AJAX polling keeping Asp.Net sessions alive

We have a ASP.Net application that has been given a 20 minute sliding expiry for the session (and cookie). However, we have some AJAX that is polling the server for new information. The downside...

Trim String In Automapper

Mapper.CreateMap<DataViewModel, DataSource>() My Source Here Contains String Values Coming from user interface. I want to trim all the string before i map it to my destination object. Couldn't...

AJAX Form Post - Not Passing Data

I have a form that that is not being passed to my controller. It is hitting the controller method, but fails in passing any parameters, 'jsonString' is always NULL. ** Note: I have also tried...

Object reference not set to an instance of an object in _Layout.cshtml after updated packages

The project was running fine until I updated all NuGet packages via NuGet Manager(I was trying to get the latest OWIN packages). This error is in the _Layout.cshtml and I have not touched on it...

Predefined type 'System.Object' is not defined or imported .net 4.6

I'm using MVC 5 and .net 4.6 to create a web API that my mobile app can connect too. Whenever I build the project I get hundreds of errors telling me that I need to add references that are already...

Join three tables with Entity Framework

I have these three tables. I wrote my own SQL code but I can't convert it for List<>. Can you help me please? SQL output: And here is my SQL code: Select H.HastaAdSoyad, R.RandevuTarihi,...

Can we change Action Method name in ASP.NET MVC Application?

This is two action method in controller with same name, i want to change this action name using attribute. [HttpGet] public ActionResult Show() { return View(); } [HttpPost] public...

.Net Core tag helper intellisense and color coding not working

I am having issues with .NET core and tag helpers. The color coding and the intellisense are not displaying or being registered when I type in asp-for. I've tried creating a new solution in a...

Deserialize list of objects in C#

I Use JsonConvert to serialize an object and save it in a database. This is a sample of the serialized string that I saved in...

ASP.NET Core redirecting to the same page after submitting a form with HttpPost method

I am developing a web application using ASP.NET Core 2.0. First of all i have a main view called NewOrder.cshtml: @using Microsoft.AspNetCore.Mvc.Rendering @using...

show only the date in @Html.DisplayFor(model => model.fec_ini)

I do have a view in MVC C# where I show the date using this @Html.DisplayFor(model => model.fec_ini) the problem is that the view shows the info 29/04/2018 12:00:00 a.m. and what I want to show...

AddDbContext not working in ConfigureServices of ASP.NET Razor 2.2

I reversed a sql server database into their respective classes and context, and all this appears to of worked fine. In the min context class, there is a line of code pointing to the connection...

Unable to get focus on Textbox when bootstrap modal popup opens

Hii I want to get focus on input textbox when the bootstrap modal popup opens <div class="modal fade nopading" id="myModalpop" role="dialog"> <div class="model-area"> <!-- Modal...

entity data model wizard crashes with oracle connection

When trying to create model with entity frameowrk database first method, the entity data model wizard crashes. I am trying to connect to oracle database. Oracle.ManagedDataAccess version...

Getting System.IO.DirectoryNotFoundException: 'Could not find a part of the path' after folder creation

I am getting the error ***System.IO.DirectoryNotFoundException: 'Could not find a part of the path' *** after creating the directory in the file system. What I am trying to do is to create the...

User not authenticating on successful login ASP.net MVC

I have a strange issue happening while creating this MVC project. Yesterday I was able to log in as a user, it was authenticated and everything worked fine. Today for some reason the user is...

How can I get current user ID using IHttpContextAccessor?

I am currently using .NET Core and I am trying to get the current user ID. I understand that System.Web is not available in NET Core, so I tried using IHttpContextAccessor. I have also added this...

ASP.NET MVC with Plesk

I have an ASP.NET MVC web application that I'm trying to publish to Plesk, but I get a 500.21 Internal Error each time about a bad module. In general, I'm not sure how to work with Plesk and...

HTTP Error 500.0 - ASP.NET Core IIS hosting failure (in-process) in Dot net core 3.1

**I had checked all possible ways to Solve this error like installed dot net core 3.1 runtime environment set AspNetCoreHostingModel as OutProcess But still getting this error when i'm trying...

How to calculate sha 512 hash properly in .NET 6

In .NET 6 code from http://stackoverflow.com/questions/11367727/how-can-i-sha512-a-string-in-c var data = Encoding.UTF8.GetBytes("key"); byte[] hash; using (SHA512 shaM = new...

InvalidOperationException: Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs'

Just upgraded a web project to .NET 6.0. Project compiles but when I run the site I get the following error: InvalidOperationException: Cannot find compilation library location for package...

A fatal error occurred. The required library libhostfxr.dylib could not be found

I'm working on ASP.NET Project with .NET 5.0. For Database creation, I've run the command dotnet tool install --global dotnet-ef After the installing, when I run this command: dotnet ef I got...

Foreign key created in shadow and appending random 1 to column name - ASP:NET EF Core

When I migrate my new models and data I get the following error for multiple foreign keys: The foreign key property 'InsurancePolicy.InsuranceSubjectID1' was created in shadow state because a...