Newest 'asp.net-mvc-5' Questions

Q&A for professional and enthusiast programmers

How to implement captcha in mvc5 application?

Hi I have developed web application in mvc5 and I have implemented forms authentication. My task is to implement captcha now. My requirement is to implement captcha on 3 unsuccessful login attempts. I ...

Favicon going back to default when opening a new window

I have changed my asp.net website favicon and it works perfectly when navigating through website's pages. I have put the favicon.png in Views/Shared/_Layout.cshtml file <head> <meta http-...

MVC Insert data to Two Model [duplicate]

I have two models LookingForaMate public class LookingForaMateModel{ [DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key] public int PropertyID { get; set; } ...

asp.net mvc bundles gzip compresstion not work

My Bundle Config is like this : public class BaseBundleConfig { public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/Models")....

MVC 5, Invalid Token

I've seen this discussed a few times but I still can't solve it. My registration process works well 99% of the time. But the occasional time I get an invalid token error when confirming an email ...

Search for a file content in c#

Hi I'm writing a c# code where in there is a string sent as a parameter input to the method. And then the inputString has to be searched in the file and the result has to be returned. Currently I know ...

View Change Smooth Like Slide Show [on hold]

I have an MVC application with two controllers each having one View attached. I need to display the View1 and then View2. I have written the backend logic but now I need to control the Display of ...

Method to Return list with different type

I am trying to make search with MVC 5, I got the logic but what I need is to have method that returns 3 different list objects I have view model in MVC 5 public class SearchViewModel { public ...

JSON serialization with a circular reference detected

I created two classes "Candidat" and "Experience". The Candidate may have many experiences public class Consultant { public int ConsultantID { get; set; } public string ConsultantNom { get; ...

Routing Attribute in Area [duplicate]

I want to use route attribute in area but i could not. it's RouteConfig.cs public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { ...

jQuery.Deferred exception: Kendo is not defined ReferenceError: Kendo is not defined

I am trying to populate data to a kendo datagrid using MVC5. Although ,I have referenced the javascript files correctly, I get the error message jQuery.Deferred exception: Kendo is not defined ...

How to compare item from 2 different models when using dynamic model in Razor View

I have 2 different models, Persons and Blocks and both have the same properties, ProjNr. And I am using dynamic model in the View. Now in the Razor view I want to check if the ProjNr from Blocks has ...

Unable to cast object of type 'DBContext.Models.Contact' to type 'System.Data.Entity.Infrastructure.IObjectContextAdapter'

I am trying to implement "Repository-Pattern" and "Edit" method in Contact-Controller is making use of "Attach Method" in Contact-Repository is throwing Error. Additional information: Unable to cast ...

Master-Details MVC 5 Example

Im a newbie on MVC and I've looking for a solution to my request but, there's not relevant information/documentation on the web. Im starting a project where I need to implement an Master-Detail view ...

Create URL in Razor View for Attribute Route containing parameters

I have the controller below with a route specified which contains a parameters matching the overload on the action. public class OrganisationsController : Controller { [HttpGet] [Route("...

how to send and receive data from serial port for server side in asp.net mvc

I am try to developing program with asp.net mvc 5 that send and receive command from serial port in server side. Actually, i have a hardware that connected to server and i want to send command to this ...

The current request is ambiguous MVC Attribute Route

Have 3 Attribute Routes [Route("{foo}_{bar}_{fee}_o_p")] ActionResult SelectFee [Route("{foo}_{bar}_{fee}_{fii}_o_p")] ActionResult SelectFii [Route("{foo}_{bar}_{fee}_{fii}_{fum}_o_p")] ActionResult ...

Client-Side events of button(Devexpress control) in MVC5

How to implement client-side events of button(Devexpress controls) in MVC5 using Razor. I have tried this one but click event isn't firing <script type="text/javascript"> function OnClick(...

ByDay in iCal is not working properly

"Daily", "Weekly" and "Monthly - same day of the month" is working correctly but when i use "Monthly- same week of month" (any week like first week/second week and any day like sunday/monday) then it ...

how Show Multiple Data From Session in a View Template Using Asp.net Web Application [on hold]

medicinecenterlist = (List)Session["medicinecenterlist"]; this session has multiple value and MedicineCenter is a moddel and have many property. Now My view page or View template how i fetch/show/...

“The name 'ViewBag' does not exist in the current context” upon server deploy (MVC5 / IIS 7.5)

I am deploying an MVC 5 web app created in VS2015 MVC template. The app works great inside VS2015 However after publish (to file system then copy) to a Windows 2008 R2 Server / IIS 7.5 - Pointing the ...

What is the importance of specifying the encoding in a ASP.NET MVC 5 project's web.config?

Can I ignore the encoding attribute in the web.config's root element? Is it safe to assume that there will not be any conversion issues in the future as long as the file is going to be in English?

Asp.Net MVC authorize a custom user which extends ApplicationUser

I'm using the built-in authentication/authorization system where the ApplicationUser needs to log in and once authenticated, he is signed in with the SignInManager. I also have a different user, ...

No parameterless constructor defined for this object. Object type 'System.Web.Mvc.SelectList'

I have looked at different versions of my question and nothing seems to be working so I have decided to ask mine hoping that someone might see something I dont in this. So I have a controller, ...

Html.ActionLink Javascript in href

I am trying to generate the ActionLink via helper method in the following way: return helper.ActionLink(linkText, actionName, controllerName, route, attributes); The values that I pass in are the ...

Cannot submit two dimension `List` from view to controller

Class CreateActivityViewModelwill be passed to View. public class CreateActivityViewModel { public List<List<int>> SelectedDepartmentIds { get; set; } ... } In the View, using these ...

Adding Plugin Attribute in MVC5 htmlAttributes

Hi Im new to MVC5 and I just want to ask how can I add the attribute for my Editor so i can add phone mask in it Heres the code @Html.EditorFor(model => model.PhoneNumber, new { htmlAttributes =...

Casecade DropDownList w/ Ajax Binding to Model

Looking for some help on binding the AJAX value(members_exams_proctorname) into the model so it will save during post. The school drop down work and will get the values of the proctor name. When I ...

How to save database changes in ASP.NET-MVC5 after clicking “Ok” on SweetAlert [on hold]

I am doing an if/else conditional for the SweetAlert function isConfirm() and would like to save database changes via db.SaveChanges() if someone presses "Yes" and cancel if pressed "Cancel". How ...

create a random URL with each Instance

I'm working on the security part of one of the upcoming websites developed based on ASP mvc. Here the target is like below. I enter say localhost:12345 I get redirected to localhost:1234/Login, But ...

asp.net mvc identity manually login custom user [on hold]

I have a CustomUser which extends ApplicationUser. I am a little confused on how to operate on CustomUser. I've been told I need a UserManager<CustomUser> so I tried the following: var manager =...

How to utilize C# properties correctly in this specific ASP.NET MVC scenario?

I have properties defined in my view model like so - public string FullName { get { return FirstName + " " + LastName; } set { FirstName = ...

Insert Records to a custom table using details page asp.net mvc5 [closed]

i have a class called persons and i am displaying using grid.mvc. I want when one click to view the details of selected row it should display the details then on the details view if he clicks ...

Asp.net MVC 5 cannot use Html Helpers in a Razor view inside a class library project

Am making a Plugin architecture application using Asp.Net MVC 5 so I created a class library project that will contains some controllers and some embedded Razor views. everything works fine i made ...

Microsoft.IdentityModel.Clients.ActiveDirectory.AdalSilentTokenAcquisitionException: Failed to acquire token silently. Call method AcquireToken

I configured my MVC webapp using the built-in "Configure Azure AD Authentication" function and it provided me with the following code: public async Task<string> GetTokenForApplication() { ...

Bootstrap modal form showing off page

I have a template which I use for modal forms but suddenly, while adding it to an app Im working on, the content of modal form is being rendered off the edge of the page as shown in the image ...

Server-side rendering of component fails using ReactJS.NET

I'm currently trying to get some ReactJS-stuff (from different tutorials) to be rendered on server-side using 'ReactJS.NET'. However, I always get the following message: Could not find a component ...

populate dropdown options based on another dropdown selection in mvc

I have 2 drop down one (i.e) mutualExcParam. It has 3 options. Based on this option selected, need to populate a another drop down (i.e) agencyRetrieve. This is done via JSON request and working fine ...

The best approach to create Video tutorial website using ASP.NET. [on hold]

I got a requirement to create video tutorial website. Length of video could be up to 400MB. Please suggest the best way to manage video and video streaming.Should I go for any media server or ...

How to use authorisation with user roles with my own database

As the question states I would like to check what type of user is logged in by using data annotation [Authorize(Roles="Admin")] I have seen multiple questions and tutorial but none of them explain ...

How to implement an MVC global action

I'm working on adding globalization/localization to a fairly large scale application. Everything is complete except for the views themselves. My approach so far is to add a global action that every ...

Best practices for redirect to login page if session expired

I want to redirect the user to login page, if session expired. I found many ways to do this but what is the best (or default) way in ASP.Net MVC5 with OWIN? Probably it works out of the box? But How? ...

Configurable Application Insights Instrumentation Key

How can I best make the Application Inisghts' Instrumentation Key configurable in a way that allows an Azure Administrator to manage the settings for an App Services deployment of an MVC5 web ...

How to pass two same object from view to controller

I have a panel like below: and the view code is: <div class="panel panel-default"> <div class="panel-heading" role="tab" id="headingFour"> ...

How values of ViewData and TempData are maintained in Asp.Net MVC5? [duplicate]

I have googled much but could not find how the values for TempData are maintained? As per my assumption, The values stored in ViewBag/TempData are passed with HttpRequest. Is there any cookie ...

Asp.Net Mvc Consume RestApi with content type as Multipart/Mixed

I need to use a restful service which is giving me response in multipart/mixed .Below is the sample response frok tje service --uuid:aaaaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Content-Type: application/...

In MVC 5 - How to compare 2 boolean values and set it as a third booelan in View?

I have View @Html.HiddenFor(x => Model.IsPersistable}) Model public class MyModel() { public bool IsPersistable{ get; set; } public bool StoreAsIndiv {get;set;} public bool StoreAsOrg {...

Bundle JS files using CDN and integrity attribute

In ASP.NET MVC 5, is it possible to use BundleColletion.UseCdn and have it render with the HTML integrity attribute? For example, is there someway to make this: bundles.UseCdn = true; bundles.Add( ...

how to update Many to Many table in Asp.Net MVC 5 with Identity table and Custom table

i need to make many to many relation with Identity table and Custom table and i have used the same logic in this answer but the problem i can not add anything to the new many to many table here is ...

Is there a way to dynamically resize components in a html/cshtml page according to the current window size?

Right now I have a webpage that contains multiple panels created using a foreach loop that contains textareas/textboxes. When I resize my browser window, it completely screws up the UI as it shifts ...
Translating... 0%