mvc ASP.NET Web Architecture Design - Part 2

I've actually asked about this already in this post although we've gone back to the drawing board and found it's much more difficult than we initially thought. We develop a large (and very much relied upon) Intranet system which has evolved tremendously over the years. The problem is that it uses frames to have a menu on the left, a header at the top and the main page thereafter. This is done to make sure the other elements are static whilst you're able to scroll through the pages. Now we've mvc UpdateModel with SelectList

I have class named Product public class Product { public virtual int Id { get; set; } public virtual Category Category { get; set; } } Please tell me how to update Category with UpdateModel method. Below you'll find category code in View mvc MVC custom route handler/constraint

I need to implement an MVC site with urls per below: category1/product/1/wiki category1/product/2/wiki category1/sub-category2/product/3/wiki category1/sub-category2/sub-category3/product/4/wiki etc. etc. where the matching criteria is that the url ends with "wiki". Unfortunately the below catch-all works only in the last part of the url: routes.MapRoute("page1", // Route name "{*path}/wiki", // URL with parameters new { controller = "Wiki", action = "page", mvc Redirect POST data

Short version: how can we send post data while redirecting to an "external" website? I'm using MVC and I want to redirect the user to when a username is not found, to try to log in the old system. Long version: Scenario: We have a site with a login form on the index.html. The login form POSTs the data to We have made a new version of this private part of the site: Some custom mvc Getting at ViewData.Model from spark template post

I am trying to convert my spark views to use ViewData.Model instead of the namevaluecollection so that I can use AutoMapper to map my dto's to entities before it gets into my action method. I can access the viewdata.model from the view, but upon posting back the data, viewdata.model is null. here is some sample code: in my view: <viewdata Message="string" model="MyDto" /> ${Model.Id} < -- displays MyDto.Id In my filter on the server I am trying to do: var model = filterContext.Contr mvc Show a nice error view in ASP.NET MVC and still cause ELMAH to send a message

I'm using the filter from MvcContrib which causes nice error pages, my own views, to be shown when an error occurs. The problem is that when that happens, ELMAH doesn't send me an email about the problem and I still would like to know that something went wrong. It seems the key is in ExceptionContext's exceptionHandled. When set to true, ELMAH doesn't send the email and I get my own view, if I set it to false ELMAH does send the message but I get an ugly message from IIS. Any ideas how to show mvc Use of "stores" within a web application

I see heavy use of "store" objects in the web app I am working on. Is there a name for this pattern and would you say these types are in the BLL or DAL? These stores contain fragments of what I would consider a classical DAL type, associated with a single type. For example, we have a TabStore containing methods for the persistance and retrieval of Tabs. Within each method in the TabStore there is code to invoke the appropriate NHibernate query. What are the pitfalls (if any) of working with mvc RenderAction in an HtmlHelperExtension Method?

I am trying to call the RenderAction Extension Method within my own Html Helper: System.Web.Mvc.Html.ChildActionExtensions.RenderAction(helper, "account", "login"); this is so that along with some additional logic, I would like all html helpers to use a common method name structure when calling it on the view: <%= Html.CompanyName().RenderAccount() %> but the problem I am having is that, will complain about not finding the actual route it needs to process. It does not take in mvc Bast Practise: ASP.NET MVC Controller/Action with multiple object types

I'm looking for the best method for the following issue I have. I current have a large number of objects that all inherit for a single base object and are all very similar. Is there a solution available the will allow one create action and one edit action without needing to replicate a lot of the same code. So for example I might have a person object: public class PersonBase { public string FirstName { get; set; } public string LastName { get; set; } } And then I will have a number of o mvc Model design in ASP.NET MVC

I am constanstly having problems with model design in MVC. Mostly all of my projects require some entities that are to be created, edited and deleted. Most of these entities have some common properties like creation date, modified date, author, modified by and in some cases even more descriptive properties are common. Because of that I have one single DB table to store them. For instance, Documents table and we store Invoices, Quotations and other business documents in it. I am using Entity Fram mvc Pro MVC Framework code question

The following line on page 110 of Pro ASP.NET MVC Framework does not make sense to me: string links = ((HtmlHelper)null).PageLinks(2, 3, i => "Page" + i); I don't understand what is the null doing in the above statement? I was unable to do .. HtmlHelper.PageLinks(....) Is the PageLinks Method an extension method? mvc ASP.NET MVC Validation of Script Tags

I want to prevent a user from entering any <script> tags inside a textarea box I have called story using very similar code to this: if (ArticleToCreate.story.Contains("<script>") == true) ModelState.AddModelError("Story", "No script tags allowed!"); Unfortunately this won't work because it's looking for <script> exactly as it is rather than looking for <script>some code</script> or some code` Can anyone help? I want to use very similar code to as mvc Why does the selected radio button at runtime differ from my programmatic setup?

I have data model classes as follows: public class QuizItem { public int QuizItemId { get; set; } public string Question { get; set; } public IEnumerable<Choice> Choices { get; set; } } and public class Choice { public int ChoiceId { get; set; } public string Description { get; set; } public bool IsCorrect { get; set; } } I made a setup in a controller action as follows: public class HomeController : Controller { mvc How to determine if the view is for GET or POST in ASP.NET MVC?

MVC use action attributes to map the same view for http get or post: [HttpGet] public ActionResult Index() { ViewBag.Message = "Message"; return View(); } [HttpPost] public ActionResult Index(decimal a, decimal b, string operation) { ViewBag.Message = "Calculation Result:"; ViewBag.Result = Calculation.Execute(a, b, operation); return View(); } In the MVC view, how can I determine if the view is for http get or http post? in Views it is IsPost @{ var mvc Best way to present a hierarchy of options for selection in MVC Razor view

I have to create a form that presents a hierarchy of options to the user and I can't seem to get it correct. So if I have the following parent child relationship (the level is the stage the item is shown): Option1 (Level 1) Option3 (Level 2) Option16 (Level 4) Option17 (Level 4) Option18 (Level 4) Option4 (Level 2) Option11 (Level 3) Option12 (Level 3) Option5 (Level 2) Option13 (Level 3) Option14 (Level 3) Option15 (Level 3) O mvc Using $.getJSON in .NET MVC 3.0

I want to use jQuery.getJSON function in ASP.NET MVC 3.0, so I wrote the code below for test: <input id="btn" type="button" /> <script> $("#btn").click(function () { $.getJSON("/Location/GetData", null, function (data) { alert(data); }); }); </script> and I have a LocationController with below method: public JsonResult GetData() { List<int> result = new List<int>(){1, 4, 5}; mvc Automapper list to int (count)

I'm creating ViewModels in my MVC application. We are using automapper for domain model to view model conversion. My question is I keep getting a circular reference error when doing ajax stuff in MVC (seems like it's the JavaScriptSerializer that's causing problems), so instead of getting back a list of Projects, I just need the count (because that's all my view model needs). Here is a sample of the hierarchy. Thanks in advance for any advice! public class ProjectViewModel { public int Proj mvc MVC - Need to pass data from View to Controller

I need to pass some information I have in a view to the controller. When it goes to the controller, I like to then send out an email with that information. I was thinking about using the @HTML.ActionLink the view but from my understanding, that goes to an ActionResult which I do not want as I want to be able to send out an email and not go back to the View. mvc MVC + Multiple tenancy app

So I have an MVC app that should change the Website title, and header color based on the domain the app is hit from. So I have a simple table setup in SQL as such: DomainName (PK), WebsiteTitle, HeaderColor, Website Title for Domain 1, #ebebeb So I am trying to figure out the best way to return this information for each page view. Sure I can go ahead and lookup the site info in each model thats returned from the controller. But are there any other ways I can approach this? Maybe a mvc How to save data into DataTable in MVC3?

I have mvc3 application in this i have used two partial views 1.controls 2.webgrid inside controls i'm populating dropdownlists from actual database tables. using EF On index.cshtml i have one form in which need to select values from these dropdown lists and when press insert button these values should have to go to Temp "DataTable" and also show it in webgrid...I'm newbie to MVC3 and dont know how to do this. Controls.cshtml @model Mapping.Models.SecurityIdentifierMappingViewModel @using (Ht mvc ASP.NET MVC4 routing issue

I've searched Stack for ages, read the MSDN docs and used Bing but cannot see why this won't work! I've got the relevant code below + the routes. The route called Browse works just fine, but the productCode param for the Details route is always equal to nothing. If I make any mods I keep getting the 'resource not found' 404 page. ' Lives in controller called 'Details' ' Usage: Function Index(productCode As String) As ActionResult ' Lives in controller called 'Browse' mvc How to TRUNCATE all tables from aspnet schema?

I've been doing alot of testing with my new MVC App and now I'm ready to move on to a new phase of development. I would like to TRUNCATE all my aspnet generated tables, but I can't seem to figure out the order to remove all the foreign key constraints. TRUNCATE TABLE aspnet_Profile TRUNCATE TABLE aspnet_UsersInRoles TRUNCATE TABLE aspnet_PersonalizationPerUser TRUNCATE TABLE aspnet_Membership TRUNCATE TABLE aspnet_users On this, I'm getting a foreign key constraint issue on aspnet_ mvc Crystal Report view in ASP.NET MVC2

I'm working with an ASP.NET MVC 2 project using a classic ASP.NET WebForm wired up to display the Crystal Report Viewer. This all works just fine. The problem is that after I set the parameters on the CrystalReportViewer instance and render it the displayed report always indicates the parameter values are missing. Has anyone else encountered this? mvc mvc3, Roles from database

I am creating a mvc project which I want to manage the roles in the database. I have a database with a table, in the table Called Premissions I have a column (AdministratorRole) that contains roles for my mvc project, the value will hold something like 'Domain\John Smith' (the users). I want my mvc project to check this column each time it starts up. In my mvc project i am using the Authorize attribute in the controllers: [Authorize(Roles = Roles.AdministratorRole)] I was thinking mvc Image not posted to controller

Possible Duplicate: MVC. HttpPostedFileBase is always null I want users to be able to upload an image and store it on the server for later reference. Here's some code: SliderController.cs: public ActionResult Create() { return View(new SliderImageViewModel()); } [HttpPost] public ActionResult Create(SliderImageViewModel sliderImage) { if (ModelState.IsValid) { var slider = new SliderImage(); var lastSortOrder = Context.SliderImages.Select(p => p.SortOrder).Defa mvc ASP.Net MVC3 and jQuery UI Tabs

I have created a HTML layout below with jQuery UI tabs All the tab information are related to Employee HTML Code: <div id="tabs"> <ul> <li><a href="#tabs-1">Details</a></li> <li><a href="#tabs-2">Deparment</a></li> <li><a href="#tabs-3">Salary Info</a></li> </ul> <div id="tabs-1"> <p>Some fiels here</p> </div> <div id="tabs-2"& mvc How to get a form value in another form value submission

I had username and password in first form and retrieve password in another form , in which i want userame entered in first form in submission of second form. @model Network.Models.LoginDetail <script type="text/javascript"> </script> @{ ViewBag.Title = "Index"; Layout = "~/Views/Shared/_Layout.cshtml"; } <p> Please enter your user name and password. @Html.ActionLink("Register", "Register") if you don't have an account. </p& mvc Is there any difference in performance when I use constraints in ASP MVC routes?

I recently asked a question about how to create a route that would direct to the same controller with two different paths. Here was the answer suggested to me: routes.MapRoute( name: "Default2", url: "{section}/{id}", defaults: new { section = "home", controller = "Home", action = "Index", id = UrlParameter.Optional }, constraints: new { section = "admin|home" }); I also did some more research and came up with this solution: routes.MapRoute( "spa", "{section}/{id}", new mvc How to get the action name from which the user redirected to the current action in MVC4

I have two actions named 'abc' and 'def' in Home Controller. The action 'abc' returns RedirectToAction("def"). So can I get the name of the action in 'def' from which the Redirection triggered. public ActionResult abc() { //Some code return RedirectToAction("def"); } public ActionResult def() { //Some code string str = "You have been redirected from action 'abc'"; return Content(str); } How can I get this name abc in the action def ? mvc Display Media Library Picker Field image in a lists alternate item view in Orchard CMS

So the title pretty much says it all. I am using Orchard CMS v1.7. I have created my own content type (Product Categories) - this is essentially the same as a page though also has an extra field (Media Library Picker Field) to allow me to select and display a single image - this will be displayed on both the list item view and also the main page content. I use a projection page to display all content types "ProductCategories". This works well and as expected. I now want to display this additi mvc Hidden Segments Not working when added via web.config

I am trying to secure my MVC application, and I want to hide the standard folder structure from url sniffers. For example. I have a Controllers folder. If I attempt to reach it via I am getting a 403.14 status code. if I do a directory that doesn't exist: I get a 404. I would like to hide these standard mvc directories, so that you can't do directory sniffing. So here is my question: I can add hidden mvc Knockout mapping plugin trouble getting binding properties

I'm trying to understand knockout in combination with the knockout mapping plugin. I've an MVC application returning a model (an array of customers). My controller: Public ActionResult Index() { List<Customer> customers = new List<Customer>{ .....initializing-code for the customerlist }; return View(customers); } in my View i have a script as follows: <script type="text/javascript"> function ViewModel() { var self = this; mvc NHibernate session is closed when refreshing page

This is another strange problem I've encountered this days!!! I've created and MVC 4 app using nhibernate. and added a filter attribute named [LoggingNHibernateSessionAttribute] on my HomeController which manages session for each action. I've followed 'ASP.NET MVC4 and the Web API published by Apress'. public class LoggingNHibernateSessionAttribute : ActionFilterAttribute { private readonly IActionLogHelper _actionLogHelper; private readonly IActionExceptionHandler _actionExceptionHandl mvc how should I implement table per hierarchy entity into views

i have implemented table-per-hierarchy pattern into one of my entities and it looks like this: atm, sube and acikhava entities are basically derived from mekan entity. there is no problem with these. well, what i want to know is, how should i implement this into CRUD views. all of these entities have their own viewmodels, and mekan itself is not meant to be created by itself, the user can only create an atm, sube or acikhava, because mekan is an abstract entity. but i can't just set the mode mvc Migrating EF Code First in multiple instances

I have an MVC app that using EF6 Code First. I want to deploy this app to multiple datacenters. On deployments that have migrations, I can write a script to migrate them all as simultaneously as possible, but if one datacenter is slower, then the calls could all be rejected since the schema no longer matches. A script that tried to coordinate would also make rolling upgrades impossible. Is there a way to make EF at least attempt to run the query even though the schemas don't match? Is there a d mvc Data cant pass into database MVC3

I'm doing a website using MVC3 with dynamic data that have to put into database. However i cant seem to find out why is it not append into the database after i create. Here is the Controller: using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Web; using System.Web.Mvc; using FYPMvcApplication.Models; using System.Web.Providers.Entities; namespace FYPMvcApplication.Controllers { public class CreateController : Controller mvc How to handle DBContext when using Ninject

I am trying to use Ninject and OpenAccess for the first time. Please help me with the following. Here is what my project looks like... public class ContentController : Controller { private ContentService contentSvc; public ContentController(ContentService contentSvc) { this.contentSvc = contentSvc; } } The following class is under a folder in my web app. public class ContentService { private IContentRepository contentRepository; public ContentService(IConten mvc Using MVC dropdown list how to edit form and show the data in dropdown and previously selected item in dropdown?

I am using MVC4 and displaying categories in drop down list. Foam allow user to edit the previously added data. So when i perform update action all the other data that user enter can easily displayed but who to display the selected category value from drop down list and show that valve in drop down? Controller using (var catRepo = new BusinessLayer.Repostories.CategoryRepository()) { ViewBag.VBCategoryList = new SelectList(catRepo.GetAllCategories(),"CategoryId","Name"); } View @Html.Dro mvc Umbraco MVC4 IntelliSense not working

I'm working on a few Umbraco projects that use MVC4. The MVC intellisense doesn't work within visual studio and I get lots of errors underlined. But when I run build the project, I don't get any errors, and when I run the site everything works fine. I'm using Visual Studio 2013 and I created a new MVC4 site and compared the web.configs within the Views folder and they're identical. I'm pretty sure it's not a code problem as my colleague is using the same code and he doesn't have this problem. mvc ASP.Net MVC 6 + WebAPI Auth - Redirect MVC to logon but 401 if WebAPI

I have a AngularJS + MVC + WebAPI where I'm trying to: - Use standard (individual accounts) for MVC authentication; - Use those same users and password for WebAPI based authentication. Problem, from AngularJS everything works fine, the cookie exchange happens, and Web API returns the value, but when I'm trying to access the WebAPI from Postman, I get a redirect to logon page instead of a 401 Unauthorized. What is the easiest way to achieve this? Do I have to subclass Authorize and implement mvc Asp.Net MVC relatives paths for two application pointing to same code base

Hi I have a confusion that I am publishing my application on two server. The path for both is like:- and So for including any script, css or images, I have to given two path like:- <img src="~/images/ajax-loader.gif" alt="loading" /> and <img src="~/myapp/images/ajax-loader.gif" alt="loading" /> is there any way so that I do not need to put scripts twice. I have tried:- <img src="./images/ajax-loader.gif" alt="loadi mvc Session timeout does not work ( is set in web.config )

I used the ClaimsIdentity Framework to set up auth in one of my applications. I added those lines into the web.config file like decribed in this question. <sessionState mode="InProc" timeout="1" /> I let the application run overnight, but I was still logged in. I'd like to set the session timeout to 30 minutes, any suggestions ? ASP.NET MVC Version: mvc MVC - public list inside the model class

I am fairly new to MVC, starting a new project and would like to ask before i proceed on before its to late to change or its more hassle to change. Can i add my list inside the model? currently i have my code like this: or should i put my list in another folder perhaps Service? im not sure. Models/Filters/ObjAdmissionsRegion.cs namespace EC.Dashboard.Models.Filters { public class ObjAdmissionsRegion { public string ArgName { get; set; } public int ArgPk { get; set; } mvc ASP.NET MVC and mixed mode authentication

I have a scenario whereby I require users to be able to authenticate against an ASP.NET MVC web application using either Windows authentication or Forms authentication. If the user is on the internal network they will use Windows authentication and if they are connecting externally they will use Forms authentication. I’ve seen quite a few people asking the question how do I configure an ASP.NET MVC web application for this, but I haven’t found a complete explanation. Please can someone provide mvc In Mvc, while using RedirectToAction("ReqAction", odetails) getting err as "Input is not a valid base 64 string as it contains non base 64 character"

If passed without the object its works fine by return RedirectToAction("ReqAction"); In model used public HttpPostedFileBase Provisionforattachment { get; set; } to store the file in database. Converted to bytes in the previous model to store the file in database. byte[] UploadedFile = new byte[oPModelViewObject.Provisionforattachment.InputStream.Length]; oPModelViewObject.Provisionforattachment.InputStream.Read(UploadedFile, 0, UploadedFile.Length); Tried

  1    2   3   4   5   6  ... 下一页 最后一页 共 278 页