Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
It seem like mvc 3 team decided to bring in a feature for dynamic data exchange between a controller and a view called the viewbag but it is A good thing against the strongly typed view we all know about? What are some of the positive and negative aspects to using the ViewBag versus using a strongly typed view?
The ViewBag is the same thing as ViewData in previous ASP.NET MVC 1 and 2. It just happens to be dynamic instead of needing to use it like a dictionary with keys. I don't think this will replace strongly typed views at all and in fact you should use Viewdata/Viewbag as little as possible. Always use strongly typed views whenever possible since it will lead to fewer errors if the names in your Viewdata/Viewbag change and make the HTML cleaner by not having ViewData casts all over the place.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am in confusion about the data access technology in mvc4 whether we should use Entity Framework or Linq or something else which is better than this ?
I have research much in this topic and not satisfied with all.?So can you help me about this with proper Detail?
The question will have answers upon user based opinions and experience.
This is what my personal recommendation is Model:
Take this as a Tree View Structure
1. Controller
2. ActionMethod //call the desired Factories
3.1 View Factory //to get data in DB
3.2 Domain Factory //to set data in DB
4. Services //Interface for Caching and top operations
5. Repositories //Contains on CRUD Operations
Inside the Repositories I would prefer LINQ-to-Entities rather than LINQ-to-SQL.
A great way of UNIT OF WORK PATTERN is being explained here
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am an ASP.NET MVC developer and I am confused. What's the difference between Model, ViewModel and DTO (Data Transfer Object)? Is it ok for model to have methods that will save itself to database?
DTO is an object for passing data in case of communication between layers. It's a general pattern that is not tied to ASP.NET MVC.
ViewModel contains a data specific to particular view, is passed to that view in controller and is used in the view for rendering. It's a pattern specific to ASP.NET MVC (don't mix up with ViewModel from MVVM - they are different)
Model is a set of objects that represent your business domain. It can contain methods that will save it to DB depending of what pattern you will choose to build it (something like Active Record in your case).
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
First of all, this is my first week on MVC 4
Microsoft claims the MVC will be the best web coding solution in the future based on three level framework.
1.Yet in their MVC concept, view and model can talk without controller, can any body tell me why they made that like a circle? What's the benefit behind it?
2.Without the view_state in web form, how can I know if a page is a post back?
Any open-mind ideas are welcomed!
1.Yet in their MVC concept, view and model can talk without controller, can any body tell me why they made that like a circle?
What's the benefit behind it?
View and Model cannot talk without controller. Your view would never have known the Model if the Controller hasn't passed it to.
2.Without the view_state in web form, how can I know if a page is a post back?
Why would you even want to know such thing? This is an artificial concept invented specifically for classic WebForms to alleviate the stateless nature of the HTTP protocol and make Web development ressemble Desktop development. In an MVC application you never need to know anything like that.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
Razor view engine looks promising, so I thought it would be good to contribute with ideas and compile a wish-list of Razor features while the development is just in preview stage.
What are the features you miss today in Spark, Webforms, or early Razor release and would like to be implemented in Razor?
UPD: Why close this question??? What's wrong with creating a feedback loop to Razor developers using this media?
I would like to have a directive to switch off line breaks in HTML output.
#linebreaks off
<span>the three spans</span>
<span>will be rendered</span>
<span>all in one line</span>
#linebreaks on
The above should produce
<span>the three spans</span><span>will be rendered</span><span>all in one line</span>
Need to change source code extensions, to make sure it's not "cshtml" and "vbhtml", but something shorter, like "cz" and "vz".
I want to still be able to specify content type in some sort of directive.
Not we can do this in asp.net mvc:
<%# Page ... ContentType="application/rss+xml" %>
I'm using this for RSS.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm playing with the ASP.NET MVC Framework, trying to create a simple site.
My model is essentially:
-Questions
-Answers
-Categories
Since each Question must belong to a Category and each Answer must belong to a question - is it correct to split 'Category' into it's own controller?
What would be incorrect about creating a controller path of /Question/Category/List?
Also, if I wanted to create a search - do I then create a controller called 'Search' and use like so: /Search/Question/, /Search/Answer/? Or do I use '/Question/Search/'?
Thank you in advance for any insight.
Below is a read regarding grouping controllers
Grouping Conrollers
The above is not directly related to your question but may be useful.
Now regarding your question, I'll take it this way.. (This is just one way)..
My initial take on this...
-for Questions and Category
/Question/Ask
/Question/Edit/{id}
/Question/List
/Question/Search/{criteria}
/Category/Create
/Category/Edit/{id}
/Category/List
-for answer
/Question/Answer/{questionid}
/Question/Answer/Search/
/Question/Answer/List/Group/Question
The other approach is to separate the controller with respect to Admin and Visitor functionality. Put all the admin logic like create/update/ in one controller and split the remaining logic into other controllers. There may be +/- argument to this. But's that's an individuated opinion.
Note:
Category can exist independent of the question
A question is associated with one or more category
An answer belongs to a question and cannot exist independently.
*** The example came out of top of my head and may not be the best practice but may just give some points to ponder. :). Feel free to apply your ideas.