Questions tagged [asp.net-mvc]
The ASP.NET MVC Framework is a Microsoft web application framework that implements the model-view-controller (MVC) pattern.
559 questions
2
votes
2
answers
159
views
Building a Model using MVC 5 optimally that is Database friendly?
I'm using MVC 5 Core on my Web API and I wanted to know what is the most optimal way of storing an Array into a database? Should I store Arrays, does it matter, or should I parse the array and input ...
1
vote
2
answers
631
views
Writing business logic in view
Can writing business logic in the view(.cshtml) of an MVC application have an impact on performance (for example, Load time)? Is it the preferable way or are there any other best practices?
1
vote
1
answer
3k
views
Best way to rewrite an mvc application to an angular architecture
We have an mvc application that we would like to gradually move to an angular platform. It is a wizard style app with 6-8 pages.
We currently have a classic mvc layout. We would like to move to an ...
1
vote
1
answer
299
views
Should I inject a mapping class in an ASP.NET MVC controller
I have a discussion with a colleague.
He thinks we should inject a mapping class (for mapping the domainmodel to a viewmodel) in a controller.
He thinks we now can test the mapping class (which is an ...
0
votes
3
answers
3k
views
What is wrong with a standard MVC project?
I am discussing the architecture for a new project with some colleagues. The project is relatively small and can be considered as a 'normal' crud web application.
Everybody has come up with an ...
5
votes
3
answers
1k
views
Architecture for UI Components Re-use in ASP.NET MVC
I've done a number of LOB ASP.NET MVC projects (MVC5) and would like to re-structure how I handle some things for a new project. Specifically, I have a component that I want to re-use throughout ...
0
votes
1
answer
715
views
How to go about upgrading spaghetti code? Is it worth it? [duplicate]
I'm working on medium sized ASP.NET MVC 4 web app, that is about 2.5 years old. Around 25-30k lines of code. The project has never followed any of the good .NET design practices. It is a very tightly ...
6
votes
1
answer
2k
views
Caching data vs. caching output
I don't have much experience in caching among web applications, but I am trying to educate myself in the field and try out various techniques and approaches in ASP.NET MVC.
The majority of tutorials ...
0
votes
1
answer
3k
views
asp.net MVC 5 - Does it matter if my ModelState is not valid & I don't need it to be?
I have a top10 table (like top 10 restaurants say). Each top 10 row can have up to 10 top10items associated.
Models
public class Top10
{
public Guid Id { get; set; }
[Required(ErrorMessage="...
2
votes
0
answers
8k
views
ASP.NET: Creating an interface for a controller
Would creating a controller's interface a bad idea? I have a controller that derived from ApiController, so knowing that you can only derived one class to a class but able to derived one or more ...
0
votes
1
answer
87
views
MVC versus Webforms in a specific situation
I have seen questions similar to mine, but there are some unusual specifics to mine not covered. I have a SQL SERVER driven ASP.NET web app (website). I am using the older webforms model, not MVC. I ...
2
votes
1
answer
3k
views
How can I move from Web Forms to ASP .NET MVC 5?
I've been using Web Forms for way too long now and I want to switch to ASP .NET MVC 5 because I think that it's the "next step" for a ASP .NET developer. I also find it to generate pages a lot faster ...
4
votes
1
answer
3k
views
Large controllers in ASP.NET WebAPI, How to organize
I have a large WebApi project with a few dozen controllers. Each controller represents an endpoint prefix, just as a normal MVC project would. For example:
CarsController.cs represents http://api....
1
vote
1
answer
529
views
ASP.NET MVC models, EntityFramework and Automapper
It happens so that the best practice of using EntityFramework includes taking advantage of the IQueryable inside using block, like:
using (var ctx = new SomeDbContext())
{
...(do something with ctx)...
0
votes
1
answer
4k
views
MVC - Best practice of passing data from partial view to parent view
I am trying to create a partial view (re-used many times) that will prompt the user for data and return that value to the parent view.
My best solution so far is to pass to the partial view the name ...
1
vote
0
answers
153
views
Can I do a POST AJAX to an MVC Controller or should I use Web API?
The page is loaded as a normal MVC page. The ajax is so the user can add items to their model without having to reload the page.
Right now there is no Web API in the project. I don't want to add it ...
3
votes
2
answers
1k
views
ASP.NET MVC: where to put data-entry logic which hits the database
We do simple data entry validation with attributes on the viewmodel. Think format of an email address, mandatory clientname, format of a date, the housenumber being numeric etc.
Now there are also ...
1
vote
0
answers
57
views
Best method to allow user to choose multiple things from my DB?
So I have a "Bars" table in my database and a "Add a Bar" form which allows a bar owner or manager to add his/her business listing to my website database. I also have a "Beers" table in my database ...
1
vote
0
answers
760
views
Are there any performance considerations when reading web.config AppSettings?
I'm writing a REST service with Web Api. One of the actions reads an AppSetting value from the web.config during execution.
I would assume the web.config is loaded into memory, but during high load, ...
2
votes
1
answer
946
views
Handling a violation of n multiple unique constraints in insert
I have an asp.net mvc 5 site.
I have a places table / POCO with 3 unique constraints (URL, Email & obviously ID).
Users are able to add places - but they may violate URL or Email unique ...
6
votes
1
answer
2k
views
How to incorporate windows authentication with ASP.NET Core & AureliaJS project
We are creating a project using Aurelia/Typescript. For those who don't know what that is, it's basically a better AngularJS (opinionated). Our project runs perfect, except for the fact that we need ...
35
votes
6
answers
47k
views
Why would you ever 'await' a method, and then immediately interrogate its return value?
In this MSDN article, the following example code is provided (slightly edited for brevity):
public async Task<ActionResult> Details(int? id)
{
if (id == null)
{
return new ...
0
votes
2
answers
826
views
Can someone explain the Model in ASP.NET MVC?
I have developed in the past always classic ASP.NET solution. I am starting currently to develop ASP.NET MVC solutions, but i have a problem understanding what a Model is and what it should contain.
...
3
votes
1
answer
808
views
Which is more secure for the DB, Web API or MVC with repository pattern & EF?
I am 1 of 3 developers. The other 2 use Web API and angular to build web apps. I prefer ASP MVC with a repository and EF. The stated argument is that a service is more secure when accessing the ...
3
votes
4
answers
800
views
Using Structs to organize code
I recently ran across some code during a review that baffled me a bit. The dev was using structs to organize code within a larger file. I personally don't like the practice but wanted to hear others ...
1
vote
2
answers
9k
views
MVC and use of partial class for Controller
I have a webpage and frontend contains pages for Customer, Product and Order part and other parts may be added.
The actual implementation is that every part(modul) has its own Controller and every ...
0
votes
1
answer
1k
views
How to create a single login service to use it in multiple sites ? (similar to Google, Microsoft Account)
I want to implement login system where same user account can be used to login in different web applications. How can I achieve this ? I want to make a similar architecture to Google and Microsoft ...
1
vote
1
answer
978
views
Adding support for privileges to an ASP.NET MVC application already supporting roles based authorization
I currently have a system where there is a user table, a role table, and a user-roles association table, where one user can be associated to multiple roles (like Admin, BasicUser, etc.). I am able to ...
-2
votes
1
answer
1k
views
Why C# ASP.NET MVC Code First POCO Classes must have getters and setters?
Why in, C# ASP.NET MVC Code First project, POCO Classes must have getters and setters ( {get; set; } ) in order to work?
public float data { get; set; }
or in db context class
public DbSet<SGD....
0
votes
1
answer
146
views
Questions regarding my MVC application
I'm learning .net MVC while developing a simple word list - Eg. When you learn a new language and create a list of words related to a certain topic.
I don't think I'm following the rules or good ...
1
vote
1
answer
562
views
Consume ASP.Net REST API service
I am creating ASP.Net REST API application and stuck on the part where I should consume the REST service.
I am not sure how to find the way let me accomplish the following:
1. I don't want it to be ...
5
votes
1
answer
1k
views
Two MVC projects(API and Web), should ViewModel be in a common library or in each project?
I'm creating a .NET MVC solution that will have two web projects, one for API and for Web. Some models, such as customer, will be the same between the two projects.
Is it best to have them kept in a ...
1
vote
0
answers
121
views
How to deal with weekly schema updates on database production server? (ASPNet MVC and Entity Framework)
I'm working with scrum methodology.
thus weekly schema updates are performed to the final product. However our customer is already populating the database. How can I update the database without ...
0
votes
1
answer
225
views
How Common/Acceptable is it for a .NET developer to abstain from WebForms as a rule? [closed]
I work at a mostly .NET shop.
A coworker has more of a background in open-source MVC (think RoR and Spring MVC). She seems to really enjoy .NET MVC, but she practically refuses to work on Web Forms, ...
-2
votes
1
answer
119
views
Controllers and Separation of Concerns: discussing possible strategies
I've been working on a project based off of this tutorial.
Unfortunately, the controller classes in this are quite dense and have terrible separation of concerns. I should have realized this ...
7
votes
1
answer
3k
views
is "ASP.NET Membership" still a good choice for ASP.NET MVC authentication nowdays?
The last time I used asp.net 4 years ago, the "ASP.Net Membership provider" was the best way to do user authentication in an ASP.Net application.
Nowadays, is using the "ASP.Net Membership provider" ...
0
votes
1
answer
1k
views
How do I handle the potential concurrency problem of making a payment to Paypal for a limited number of items?
After doing some investigation* I have learned that I could potentially have a concurrency problem.
I'm currently building a Tournament Platform in ASP.NET MVC 5 with Entity Framework 6. So far, I'...
9
votes
7
answers
17k
views
Should I use static classes for methods that will do common tasks and would be called through out my application?
I have spent the last few hours reading up on the use of static classes and trying to figure out if I should be using them or not but still have not come to any sort of conclusion. It seems that the ...
0
votes
1
answer
843
views
How to have server call a web page for data on a timer
My question is not how to call a web page in code but rather what the correct architecture for it would be.
I have an MVC web app that displays certain data from our database when the user visits a ...
0
votes
1
answer
3k
views
Dependency injection multiple instances or only one InrequestScope
I'm trying to understand what happens with dependencies (Ninject) when a same Interface in injected in multiple classes. I am specifying InRequestScope for my bindings so as I understand there should ...
0
votes
3
answers
483
views
My ASP.NET MVC controllers seem like in mess
I am developing program with asp.net MVC and I feel like I'm doing it wrong in these parts:
I'm populating all process in controller, because I don't know how to put it in model (how to call it). I ...
2
votes
1
answer
1k
views
Is it good practise to access methods of one controller from another in MVC?
I have some methods defined in a controller which most of them returns JsonResult, and some returns PartialViews.
So I have two questions,
1) Is it a good practice to access those methods that ...
0
votes
1
answer
2k
views
Using "Id" as Primary Key in green field Dapper Contrib MVC 5 site
I am creating a new site and will base it on ASP.NET MVC 5 & Dapper Contrib. I want to go all in with all these technologies - and get all the time saving / convention over configuration / terse ...
0
votes
1
answer
105
views
Need help with figuring out a better method of my application layout, please
I am working as the sole .Net developer at a company and I have been tasked with a very large and complex project, an internal intranet site for inventory and time tracking. I have built a project ...
0
votes
0
answers
2k
views
Using @Hidden or passing through BeginForm?
I have a small question about the following answer from a stackoverflow question.
There seem to be 2 ways to pass parameters through a @BeginForm() to a Controller.
Using a Hidden field:
@Html.Hidden(&...
3
votes
2
answers
216
views
Rails' MVC vs Microsoft MVC - where to put logics?
Some time ago I switched from Microsoft ASP.NET 2.0 (WebForms, never knew Microsoft's MVC) to Ruby on Rails and learned it's MVC approach, after which some things in ASP.NET MVC seem to be weird.
In ...
-7
votes
2
answers
3k
views
Referencing a C++ DLL from within a C# ASP.NET project using Visual Studio Community 2015 [closed]
This question might be a little odd, but is there any specific way to import a C++ reference into an ASP.NET C# project?
The problem I am having is that VS is giving me the following error:
Error ...
1
vote
0
answers
103
views
Project Design - Separating JS and C# tasks - Risks vs Benefits
I'm in RFP phase working with outsourcing vendors on the 100% rewrite of a fully operational prototype asp.net app that I wrote, to make it commercially viable.
I have an idea for a project design ...
-5
votes
3
answers
4k
views
What handles the work of video streaming in ASP.NET MVC?
I want to play video using ASP.NET MVC. In my understanding, the model deals with the video files stored in file system and data in database. The controller retrieves the path of video file from model ...
3
votes
2
answers
1k
views
Most efficient strategy for search large text areas for multiple values
I have a requirement for a service that does the following.
Take a block of text and identify the server names in it (by name or ip address). So given:
Lorem ipsum dolor sit amet, consectetur ...