Newest 'asp.net-mvc' Questions

Q&A for professional and enthusiast programmers

Calling a Controller Method with parameters from a View when a button is clicked (cshtml, c#, MVC)

This is my Controller, where I would like to call the method AnswerASelect. namespace VotingWebApp.Controllers { public class HomeController : Controller { public async Task<...

Grouping Date by month in MVC Chart

i would like to count the number of new users in one month. However this is the output i am receiving. How do i go about grouping the repeated months into just "Jan", "Nov". Thank you so much for your ...

WebGrid with RadioButton

I want to select a row from a WebGrid by cheking a RadioButton and, when I click the button Show, a partial view a will be loaded with the informations from the row(like a form). What do I have to do,...

Setting a value before the submit doesn't send it to the controller

I have a view with multiples forms, each one submit should submit a hidden field with a specific value and all of the share the same model. From my controller I set the value before rendering the view,...

Open excel file for editing in asp.net MVC

I am working on asp.net mvc, my requirements are as follows Upload any excel file(s) Delete any excel file(s) Edit any excel file For this i followed a tutorial and i am able to perform steps 1 ...

ASP.NET MVC Passing a List of Lists to the ViewBag

I have an Entity with a definition of: public class Skill { public enum Level { Begginer, Intermediate, Advanced } public int Id { get; set; } [Display(Name ="Skill Group")] public ...

Why am I getting CS0426 error when I give project name 'MvcApplication' using ASP.Net?

This is really weird. As it sounds, I have tried to create a project/solution named MvcApplication using Visual Studio 2015 (Enterprise). I choose MVC template and leave all default as it is. It ...

Azure MachineKey.Protect giving different results on each request

I'm using MachineKey.Protect to encrypt some cookie data, but something really weird happens. When I refresh the page - I'm expecting the same exact cookie value since it doesn't change - but it ...

.NET MVC get current page and controller in shared layout

I'm trying to fetch the current page from my shared layout in .net mvc app so that I can load a different favicon icon for the 2 different pages. I've tried something like following: @if (Request....

How to determine if Copy Local is necessary

I tried to reference System.Device in a Razor view of my MVC C# project. It complained that the reference was missing even after I added it to the project. I did not have the assembly in my GAC, and ...

How to enable remote access in my local application - IIS Windows 10

I have an application in my machine, and i can access it by localhost/myapplication normally, but I'm making a integration with a payment website, this website needs an url to send me notifications ...

AMP pages working from google

I make AMP pages and want to be it working from google, the main page work but other pages doesn't work.want put this path "https://www.google.com.eg/amp/" before any page in my site such as https:/...

T4 Template - Add Extra View output to MVCView

I have added the CodeTemplates to my ASP.NET MVC Project in VS2015. There I changed in MvcControllerWithContext the Controller.cs.t4 file. This works very good as i have tested it, changed also the ...

How do I get one model and post to another properly?

I am building an online store and I am currently working with 2 models. The Shirt model displays all the details about the t-shirt (photo, description, base price, sizes)which is currently on display ...

ASP.NET MVC 5 application on Azure won't log exceptions

I'm having difficulties getting uncaught exceptions logged when deploying my ASP.NET MVC 5 application to an Azure App Service slot. When an uncaught exception occurs, the app rightly returns a 500 ...

JSON Deserialization - String Is Automatically Converted To Int

When I deseiralize the JSON to the C# object below, either using Newtonsoft explicitly or via the model binding mechanism of ASP.NET Web Api, the string id value is automatically converted to int. I ...

How delete “vbLf&” in vb.net

When i passing <td> row to controller, i receive that string: vbLf &" 364091670" & vbLf &" Instead of just string variable: 364091670 Look the pic: that my function: ...

Authorize controller access using Authorize Attribute

Building MVC5 intranet app. User in AD group can't access the controllers that have Authorize attribute on them. IIS using Windows Auth only, everything else disabled. I verified the user is in the ...

Additional information: Object reference not set to an instance of an object. when using ninject [duplicate]

i use Ninjecin asp mvc . when i using the insert and return list , it work but when i using edit it show me this error . whats the problem ? enter image description here Interface : bool ...

How should look tests for IService, IRepository [on hold]

I wonder how should I test all this stuff public interface IProductRepository : IRepository<Product> { Product GetById(string id); } Concrete repository: public class EFProductRepository :...

xammp umError: MySQL shutdown unexpectedly missing dependencies improper privilege shortdown mysqlerror log

MySQL shutdown unexpectedly. This may be due to a block port, missing dependencies, improper privilege, a crash, or a shortdown by another method. Check the /xampp/mysql/data/mysql_error.log file and ...

Cascading Dropdownlist from database in MVC

I'm having trouble about cascading dropdowns. Its not working whatever i try. I am trying to capture StateID from the 1st dropdownlist and then filtering the 2nd dropdownlist... (il=state, ilce=city)...

Trying to map two properties together, getting error “LINQ to Entities does not recognize the method 'System.String ToString()' method”

I'm using AutoMapper to map the properties of two objects together, but I'm getting the error LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method ...

Problems with bundling and relative paths

to describe the problem I will start with the background. So in our project we are using the CssRewriteUrlTransformWrapper from this answer to adjust relativepath like ~ public class ...

Resource in Content folder not found using ASP.NET MVC

I am trying to load a trackCues.vtt file that is stored in my solution in the following place: and I am trying to load this resource in my view in the following manner: <video style="margin-top:...

How to bypass a not nullable property when displaying a model in view?

So I have this property in my model : public string ImageBase64 => System.Convert.ToBase64String(ImageData); I cannot make it nullable by addding a ? in after the string part, because i get : ...

The name Section doesn't exists in current context: ASP dot net MVC

I am trying to send the css into RenderSection in _Layout.cshtml file. That is @RenderSection("mycss", required: false) But when I try to send the css from a razor view (.cshtml file ) it says, ...

why to use select statement even though inserting values in sql server database,using entity framework MVC application

I am very new to the MVC,Entity framework application and am still learning. I have a query. I am inserting the values in SQL server database using Entity Framework and MVC application with the stored ...

Why do I get a null reference exception while trying to fetch an Image from cloudinary?

I have my Cloudinary profile set in a controller: Account account = new Account(); account.Cloud = ConfigurationManager.AppSettings["CloudName"]; account.ApiKey = ConfigurationManager.AppSettings["...

Dynamically hidden list items in _Layout nav bar not showing

Using MVC5, I am dynamically setting the style to hide and show menu items in the _Layout nav bar. The DOM elements update correctly when I inspect the html after the URL helper sets the style, but ...

ASP.NET Entity Framework issue: one-to-one, two objects mapping to same table

My ASP.NET MVC (.NET Core Framework 1.0) code consists of two models: public class BusLine { public int Id { get; set; } [Column(Order = 0), ForeignKey("RouteA")] public int RouteAId { ...

how to delete item from model list in view?

I have list of model and send it to view. i want delete a few row of model list. how to delete from list in view? List<Booking> models = new List<Booking>(); foreach (string id in items) {...

Ajax form results to resource not found exception

I have searched in different forums to solve my issue..But every attempt was failed.I have modified my content with those solutions desscribed in the forum. I have got the following controllers ...

MVC 5 - When deploy to IIS, relative references are broken

MVC 5 using Visual Studio 2015. When I run in Visual Studio, it runs as https://localhost:44396. When I deploy to IIS, it runs as https://localhost/MyWebsiteName:44396, so my relative references like ...

How do I keep from duplicating data that may change in a .NET configuration file?

I have a username and password key within my web.config file. I need to access those keys within the web.config in a provider. Is this possible if so what is the best way to accomplish this? This is ...

Error TS1128 Build:Declaration or statement expected in Angular 2

I have update my dependency of asp.net core 1.0 to asp.net core 1.1.Using the nuget manager. I , have updated all the list in the upload mention in the nuget update. Now, I am getting a Error TS1128 ...

Passing data from view to controller action(httpget) to another view to same controller action (httppost)

I'm trying to enable posting Comments from the view where I display a Forum Post by id. That's the model which my view receives: @model PostViewModel the Model has and "Id" property, which I ...

ASP.NET Redirect without processing the View

When I redirect, it still processes the View which will always error because I haven't set up a Model object. How can I force the website using RedirectPermanent("/page",true); and not have to ...

Benefits of jq grid over mvc web grid

I am using mvc web grid in an mvc application but i also want to use jq grid will it be more suitable than web grid.

The UPDATE statement conflicted with the FOREIGN KEY constraint error?

When I try to update a user profile in my app i get the following error: The UPDATE statement conflicted with the FOREIGN KEY constraint "FK_dbo.UserDetails_dbo.Companies_CompanyId". The conflict ...

Display dynamic column name using angularjs for html table

I just prepared a data and want to display in html table but the problem is that every time I call the $http service it returns n number of columns. So basically what I want to display is that first ...

how to pass both session and Request.URL in unit test c# controller

I have a controller which requires both Session state object and also Url Helper to be mocked from unit test and in this regard i have created the following below code [TestMethod] public ...

Specific Roles can access certain Actions

I want to authenticate users to Access some Actionresults in controller . Means that User should not be able to access User Management And Manager or admin should have authority to access for ...

Trying to register dependency in Ninject but couldn't due to circular dependency in Asp.Net MVC

I am new to dependency injection. My Solution structure is like this. I have added reference of AccountingApplication project to my Business and DAL projects. Now I am trying to register the ...

404 error when URL contains a '+' for a parameter with ASP.Net Core

My server is returning a 404 error when a parameter has a space encoded as a + instead of %20. I don't understand why. The route is of the form [Route("/Search/PRM1/{prm1}/PRM2/{prm2}/PRM3/{prm3}") ...

Issue with Routing while Adding MVC 5 to Webforms 4.6

we currently have a big Webforms application thats currently running on 4.6 framework. We have the webforms routing already setup. Now, we are trying to add MVC to this project and make it a hybrid ...

How to read DropDownList value with HTML Helper when using @Html.PagedListPager MVC

I have the following code in my view: <table> <tr> <td> Number of Records to Show: </td> <td> @Html.DropDownListFor(m=...

can a mvc view model be used in a details form view [duplicate]

yeah so I have a mvc application and I was trying to display a concatenated field of data... did a search and the internet showed an example where the user created a view model to do the concatenated ...

How can I convert IQueryable expression object into LINQ expression?

I need to be able to create LINQ's Where conditions/filters dynamically from a controller. Then, I want to pass these filters to a repository's method that will query the database after applying the ...

Value cannot be null parameter name: source even when IEnumerable in not null

I have the following models: public class Student { public int Id { get; set; } [Display(Name = "First Name")] public string FirstName { get; set; } [Display(Name = "Last Name")] ...
Translating... 0%