Most voted "asp.net-mvc" questions
ASP.NET MVC is an open-source Microsoft framework that implements the Model View Controller architecture standards for web development. Based on ASP.NET, it allows software developers to build web applications following the Model View Controller architecture standards, featuring a variety of features following recent trends.
Learn more…3,385 questions
Sort by count of
-
4
votes1
answer1975
viewsCalling an asynchronous function in an Actionresult?
How to make the call of an asynchronous function on a non-asynchronous controller, to be clearer follows a situation: I have a form that when saving it needs to store data in the database and…
-
4
votes1
answer362
viewsOrder of execution of Migrations
Hello! In my first job, I worked using code-first with Entity Framework 4. At this time, I noticed a limitation in it: the generated Migrations only ran in order. For example, if in my branch two…
-
4
votes1
answer662
viewsNo Auto-Increment Primary Key for CPF in Entity Framework
The scenario is as follows: I have an Employee class. A primary key of it must be the employee CPF that the user type. The Problem: the key follows a default auto increment, not going according to…
-
4
votes2
answers2098
viewsDisplay decimals (Currency) is rounding
I have an application where the price should go in format int decimal-free. int Valor = (int)(produto.Valor * 100); //o produto.Valor é um decimal The problem is when I want to display this value in…
-
4
votes1
answer329
viewsSend multiple values from my Checkbox to an Ajax call
I have a button that when I click calls my ajax function. I want to send the values that were selected in my checkbox.But what comes to my controller is only the first value of my Checkbox., Domingo…
-
4
votes1
answer2526
viewsRecover view value for controller
Goal: Retrieve view value for controller [Httppost] I created a Generic class with gets and sets public int ListarDadosCarteira_Resultado { get; set; } public string ListarDadosCarteira_Descricao {…
-
4
votes1
answer1210
viewsHow to decrease byte array size that represents an image
I have an array of bytes in Base64 that is in a string in C#. It represents an image. The size of the string is between 50 and 80 thousand characters. I wanted to know if it has how to decrease this…
-
4
votes2
answers2566
viewsLogin with Windows Authentication on IIS
I have a base Sqlserver 2008 where all users can connect to it via Windows domain, this works properly via SQL Management Studio. I am making a C# Application in MVC, and I wanted that when the user…
-
4
votes2
answers3351
viewsHow do I create a Checkbox using the Html.Checkboxfor Helper for a Nullable field?
My field is as follows in my class: public bool? meuCampo { get; set; } And in my view it’s like this: @Html.CheckBoxFor(m => m.meuCampo) Only that way it’s not allowed, because I can’t…
-
4
votes2
answers569
viewsReturn Datareader to bool field
I need to return a field that is of the type bool: public List<TB_USUARIO> ListarTodos() { var strQuery = "select * from tb_usuario"; using (contexto = new Contexto()) { var retornoDataReader…
-
4
votes1
answer623
viewsRedirect to error page when entering catch
I have a question as to a possible improvement in the method when an error occurs in a Action and redirect to an error page. At the moment, I do so on Action: public ActionResult Index() { try {…
asp.net-mvc asp.net asp.net-mvc-5 asp asp.net-mvc-4asked 8 years, 5 months ago Leomar de Souza 1,074 -
4
votes1
answer263
viewsPassing model via dynamic form parameter in . NET MVC
I created this function to generate a handle (or slug, how to prefer) for the model users, the problem is that I would like to make it more "modular", so that I can easily implement in any other…
-
4
votes2
answers123
viewsProblem creating user class (Identityuser) relationship using Identityframework
When I create any relationship with my user class: namespace Modelo.Cadastro { public class Usuario : IdentityUser { [StringLength(250, ErrorMessage = "O nome de usuário deve conter no mínimo 3…
c# asp.net-mvc entity-framework asp.net-identityasked 8 years, 3 months ago Luiz Henrique da Fonseca 41 -
4
votes2
answers483
viewsValidation of two fields with jQuery.validate and Dataannotations
Good afternoon, you guys, Next, I need to validate if one of two fields is filled, I tried to create an Attribute function with Validationattribute but not correctly validated, I think…
-
4
votes1
answer469
viewsHow to save in 2 tables at the same time
Hello, I would like a help. I have this method to save the data in two tables. public void SalvarLocacao(Carrinho carrinho, Locacao locacao) { Item items = new Item(); foreach (var item in…
-
4
votes0
answers4243
views'The underlying Provider failed on Open' C# ASP.net
I have an application that has 4 layers, which are the following : Dominio, Infra, Servico, Web in the domain I have a folder called Poco with all my Classes/Tabelas , in the Layer Infra, to test…
-
4
votes1
answer499
viewsDelete user session in ASP.NET MVC with [Authorize]
I have a web system developed in ASP.NET MVC 4. One of the features is user management. A CRUD of users. My method of login is as follows: [HttpPost] public ActionResult Login(LoginViewModel…
-
4
votes1
answer151
viewsUnique contexts of authenticated users
Using the @Gypsy recommended method in this answer (It is possible to leave connectionString dynamically?), I was able to get a dynamic connection, and using the idea of mapping a context with the…
-
4
votes1
answer991
viewsHow to use login in different areas on Asp.net mvc
I’m creating an app, where it has more than one Area, which is restricted. (as shown in the image below). My question is how to login in different areas? Details: As users of the Admin area and the…
-
4
votes2
answers353
viewsWhat is the difference between @Url.Content("~/css/bootstrap.css") and only "/css/bootstrap.css"
I am learning to program an application based on MVC4 and Bootstrap. At the beginning of the project I came across a puzzle: In the _Layout.cshtml I had <link href="css/bootstrap.css"…
-
4
votes1
answer2349
viewsWhat is the reference to Httpcontext.Getowincontext() ?
I had to abstract the Controllers of an application ASP.NET MVC for a Class Library because I’m using different technologies in the same application. However, I have the error:…
-
4
votes1
answer549
viewsDisable IIS cache
I’m having problems with IIS cache (I think the problem is he), whenever I make any changes in the database, changes do not happen on the website, keeps the old data. Changes only appear when I turn…
-
4
votes2
answers638
viewsInsert checkbox dynamically by returning Json does not display Text?
I’m creating a list of Checkbox according to the selection of a Select on the same screen. No event change of select is called via ajax javascript, the method that returns a Json with list(value,…
-
4
votes1
answer274
viewsError in Dapper query
Well, I’m trying to perform a consultation on Dapper and get the following error: The model item inserted in the dictionary is of type'System.Collections.Generic.List`1[Taxability…
-
4
votes1
answer1805
viewsHow to pass parameter to MVC controller
How to pass the text or content of a DropDownList to the Controller by pressing a button? I tried using @model and I couldn’t. I tried adding the [HttpPost] in the Controller and using the type…
asp.net-mvcasked 7 years, 10 months ago Evandro Silva 149 -
4
votes2
answers690
viewsReturn xml to preview browser Asp.net mvc
I have the following situation, I need to provide an XML file to be viewable in the browser, without the user needing to download the file, I do this by saving the file in a directory and then I…
-
4
votes1
answer72
viewsHow to capture Stackoverflowexception
Hello, I am going through some problems on the server and with the application developed in MVC... I checked that the site was restarting the application pool alone, so I went to Event Viweer and…
-
4
votes3
answers1052
viewsHow to filter a list type Ienumerable<> through another Ienumerable<>?
How to filter a type list IEnumerable<> passing a parameter of type IEnumerable<> preferably via expression lambda or linq? Based on the filter below I expect this result: {MundoId = 0,…
-
4
votes2
answers227
viewsRemove "OR" condition from LINQ query
I have the following method: bool naoUsarNomeCliente = String.IsNullOrWhiteSpace(filtro.NomeCliente); long codigoExterno; bool naoUsarCodigoExterno = !long.TryParse(filtro.CodigoExterno, out…
-
4
votes1
answer964
viewsHow to delete objects within a list?
I have the following code: using (Context contexto = new Context()) { List<Cliente> listCliente = contexto.Cliente.Where(x => x.Status == 0).ToList(); } How do I delete this result from the…
-
4
votes2
answers2552
viewsClaims Identity MVC
I’m having difficulty implementing Claims to make user authorizations in my project, I’ve read a lot but I can’t execute it. I’m using in the project the Nhibernate.AspNet.Identity may be that for…
c# asp.net-mvc asp.net-mvc-5 asp.net-identity fluent-nhibernateasked 7 years, 4 months ago Eluander J. F. Lopes 400 -
4
votes2
answers178
viewsHow to update all records of all tables that have FK of a table
I have the following tables: CREATE TABLE Contrato ( [Id [int] NOT NULL IDENTITY, [Nome] [varchar](150), [Ativo] [bit] PRIMARY KEY ([Id]) ) CREATE TABLE [dbo].[ItemContrato] ( [Id] [int] NOT NULL…
-
4
votes2
answers1153
viewsHypothesis tests with C# - Merge (sum) of values to find result
Hello, everybody. I need to solve the following problem using C# (ASP . NET MVC): I have a table in the database that contains ID and Value (decimal) as below: id: 1 | value: 100,00 id: 2 | value:…
-
4
votes1
answer46
viewsError mounting HTML table with jQuery
I need to create this screen: The problem is that the code I made generates 9 columns in a row instead of generating 3 columns per row: That is the code: @{ ViewBag.Title = "Home Page"; } <div…
-
4
votes1
answer898
viewsServer cannot attach a header after HTTP headers have been sent
Good morning, I have the following code that I use to compress the controllers using the GZip. I log in to the system normally, but if I try to change registered company the following error is…
-
4
votes4
answers1515
viewsTake a field value by id and put it into a variable
Hello, I have a field on a form that receives the id: "teste", how can I catch via javascript this value and put in a variable?? I found the following on the internet var str =…
-
4
votes1
answer420
viewsHow to translate "Errormessage" from a "Custom Attribute"
I created a Custom Attribute which is valid only if a property CPF is a valid CPF, but when locating the application I noticed that my Custom Attribute were not having their messages located by the…
-
4
votes2
answers123
viewsHow far should we follow OCP?
When developing a screen for a certain part of a system, I come across a classic situation of owning some ifs to determine what action should be taken. I then linked this case to examples of OCP…
-
3
votes2
answers578
viewsHow do I always keep my Urls in lower case?
I want all Urls on my site to be lowercase to help with SEO and to make link sharing consistent. How can I do that?
-
3
votes1
answer1363
viewsIs there a way in ASP.Net MVC, in the controller to access a variable in sessionstorage or localstorage?
I need to get the value of a variable stored in sessionstorage through a controller where this method is not passed the parameter of this variable. Session/localstorage are managed through…
-
3
votes4
answers7116
viewsHow to hide the time of a "Datetime?" field in the user interface?
The time is appearing for the user. My question: it is possible to hide the time and show only the date? How are you showing: Model code: View code:…
-
3
votes2
answers343
viewsAsp.net MVC4 on IIS 6 - Page not found
I’m having trouble publishing an ASP.NET MVC4 application on an IIS 6. The settings seem to be correct, but the browser shows "error 404". Someone’s been through it?
-
3
votes1
answer5980
viewsHow to pass parameter in an Action Link values that are in HTML elements?
I have 2 HTML elements, a TextBox and a Hidden, which have values, how to pass the values of these elements in the Action link parameter? Below the parameters docItemId and vlrImobIcms are making a…
-
3
votes4
answers3223
viewsGenerate xml through a class, even without value in the property
I am generating an xml through an existing class, for example [XmlRoot("pessoa")] public class pessoa { //[CPFValidation] [XmlElement("cpf")] public virtual string cpf { get; set; }…
-
3
votes4
answers1320
viewsLong processes in C#
I need to do a routine where the user will upload a data load file, and C# will process it and save it in the database, without giving time-out and showing the process progress to the user. My…
-
3
votes1
answer118
viewsASP.net MVC with WIF
When searching the web, I saw that it is not possible to register Assembly’s on the Razor view engine on Asp.net mvc as was done on webforms. <%@ Register TagPrefix="wif"…
-
3
votes2
answers500
viewsExtend a specific jQuery method in ASP.NET MVC jquery.unobtrusive-ajax.js
I’m using the Extensions methods @Ajax.BeginForm() to save the data via AJAX. To avoid running more than one click on the Submit button, which could cause a double Insert in my database, I decided…
-
3
votes2
answers330
viewsDisplay layout only when view is not loaded via ajax
In my project, I am developing so that the application works even if the user is with Javascript disabled or unavailable. If Javascript is not available, I load the page normally. If available, I…
-
3
votes1
answer50
viewsChange csproj value through Teamcity
Hello, everybody. I am using Teamcity for .NET. I have set up some projects, and the build-Steps basically consist of building the application with the Visual Studio (.sln) Runner and run unit tests…
-
3
votes1
answer898
viewsHow to pass checkbox list to Actionresult
I need to know how to pass the values of inputs checkboxes to the action Edit, need to pass the properties Checked and Id and store in a list of type Photo. Noting that the controller that this…