asp.net-mvc-3

How to send model object in Html.RenderAction (MVC3)

那年仲夏 提交于 2020-07-27 05:46:03
问题 I'm using MVC3 razor, and I'm trying to pass an object to a partial view, and it's not working. This works fine without sending the object model to the partial view: Html.RenderAction("Index", "ViewName"); Trying this doesn't sent the model object, i'm getting nulls instead (the object has data, and the view expects it):' Html.RenderAction("Index", "ViewName", objectModel); Is this even possible using RenderAction? Thanks! Edit: I found the error, there was an error with the controller's

How to send model object in Html.RenderAction (MVC3)

﹥>﹥吖頭↗ 提交于 2020-07-27 05:44:12
问题 I'm using MVC3 razor, and I'm trying to pass an object to a partial view, and it's not working. This works fine without sending the object model to the partial view: Html.RenderAction("Index", "ViewName"); Trying this doesn't sent the model object, i'm getting nulls instead (the object has data, and the view expects it):' Html.RenderAction("Index", "ViewName", objectModel); Is this even possible using RenderAction? Thanks! Edit: I found the error, there was an error with the controller's

IIs Error: Application Codebehind=“Global.asax.cs” Inherits=“nadeem.MvcApplication”

≯℡__Kan透↙ 提交于 2020-07-18 04:06:40
问题 I am trying to deploy my web project and I keep getting this error: Line 1: <%@ Application Codebehind=“Global.asax.cs” Inherits=“nadeem.MvcApplication” Language=“C#” %> I looked at this post: Parser Error: Server Error in '/' Application But it is currect in my project. I suspect it something with my iis7 configuration. Any ideas? Global.asax: <%@ Application Codebehind="Global.asax.cs" Inherits="tamal.pelecard.biz.MvcApplication" Language="C#" %> Global.asax.cs: namespace TamalTest { using

Image display on MVC view

帅比萌擦擦* 提交于 2020-07-16 16:45:25
问题 I am trying to display image on the cshtml file. The spam filter prevents me from typing the HTML for image. However the source is set to src= "@Html.Encode(Model.PictureLocation)" alt="IMAGES" In viewsource it shows as src= "C:\Documents and Settings\xxx\My Documents\Visual Studio 2010\Projects\MVC\TIQC_ServerInterface\TIQC_ServerInterface\uploads\FileUpload12011_03_02_11_49_22.jpg" alt="IMAGES" The image is present in the location mentioned in the src path. On execution, the page is not

Where does paging, sorting, etc go in repository pattern?

戏子无情 提交于 2020-07-16 16:34:31
问题 Where do we put the logic for paging and sorting data in an asp.net repository pattern project? Should it go in the service layer or put it in the controller and have the controller directly call the repository? Controller -> Repository is shown here for a jquery grid. But unlike that article, my repository returns IQueryable<datatype> 回答1: It should go in the Repository if your Repository returns materialized sequences ( ICollection<T> , List<T> ), etc. But if your returning IQueryable<T>

How to get User.Identity working outside controller

别等时光非礼了梦想. 提交于 2020-07-08 03:56:48
问题 I have separate project with some of my custom ASP.NET MVC helpers In one of my helpers I need to check user identity. How may I get User.Identity working there? By default it is living in System.Security.Principal in interface called interface IPrincipal 回答1: The HtmlHelper has the current ViewContext and via HttpContext you'll get the User object for the current User. In your extension Method you can use this public static bool MyHelper(HtmlHelper helper) { var userIdentity = helper

Package Manager console not working

笑着哭i 提交于 2020-05-26 10:14:05
问题 According to this http://docs.nuget.org/docs/start-here/using-the-package-manager-console I should see the PM prompt and commands like get-packages should work. With my VS2010 the Package Manager Console prompt says PS E:\myprojectfolder and none of the commands work - it issues an error saying: PS E:\project> get-package -ListAvailable The term 'get-package' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was

ASP.NET MVC - How to hide or Show a link/button based on logged in User's Role permission?

天大地大妈咪最大 提交于 2020-05-24 08:31:24
问题 I am using ASP.NET MVC4. This is my userroles 1. Administrator 2. L1 Admin 3. L2 Admin Administrator group users have permission for Settings(used adding , permission settings). View Logs, Error Reports etc. If a user is a member for Administrator group, he can see only menus which are related ti above settings. I have a menu table, having menu details. There are some functions like Delete,Edit which are shown based on the role of the current user and not availble in the top Menu . Delete

ASP.NET MVC - How to hide or Show a link/button based on logged in User's Role permission?

江枫思渺然 提交于 2020-05-24 08:31:08
问题 I am using ASP.NET MVC4. This is my userroles 1. Administrator 2. L1 Admin 3. L2 Admin Administrator group users have permission for Settings(used adding , permission settings). View Logs, Error Reports etc. If a user is a member for Administrator group, he can see only menus which are related ti above settings. I have a menu table, having menu details. There are some functions like Delete,Edit which are shown based on the role of the current user and not availble in the top Menu . Delete

Public variables in MVC 3 Razor _ViewStart

与世无争的帅哥 提交于 2020-05-13 04:32:34
问题 I'm building a site on the new Razor engine that comes with MVC 3 (and loving the new syntax!). However, I am at a loss about using public properties / constants with it. I know that with WebForms we could add a public property in code behind: public string ImageFolder { get; set; } I would like to define important variables in one global place that my views can access, starting with paths to CSS files and images: @{ Layout = "~/Views/Shared/_Layout.cshtml"; var ContentFolder = "~/Content";