asp.net-mvc-2

can i use a keyword as a propertyname in vb .net?

杀马特。学长 韩版系。学妹 提交于 2021-02-09 17:55:01
问题 I have to serialize/deserialize a class into a JSON string/and return. The JSON Strinig must contain the "error" string (like: {error:"something strange occoured", id:23, result:"xxxxx"}), which specifies the occoured error. How can i implement a class like: Public Class JsonResponse Public result As JsonResult Public error As String Public id As Integer End Class If i do this, the word 'error' is invalid. Thanks 回答1: Surround it with square brackets Public Class JsonResponse Public result As

My MVC Custom ControllerFactory works but could it be better?

混江龙づ霸主 提交于 2021-02-08 02:36:10
问题 I've looked at Ninject, StructureMap and Other Dependency Injection and Service Locator frameworks, but this question is more about learning how it works and what can be better. More to the point, I’m not interesting in looking at a Framework’s source code for Dependency Injection, but understanding how it’s achieved from beginning to end in practice/code. The code below is for a small internal project, so with that in mind let me begin. Here is my interface for returning Domain Models to my

Why is my MVC ViewModel member overridden by my ActionResult parameter?

百般思念 提交于 2021-02-07 07:17:38
问题 Is this a bug or a feature? All code below has been simplified for the sake of brevity and easy replication and does not actually do anything useful other than highlight the behavior. I have a class that includes an int named ID: public class FooterLink { public int ID { get; set; } } In my controller, I have an Edit actionresult that takes a parameter called 'id': public ActionResult Edit(int id) { return View(new FooterLink() { ID = 5 }); //notice that I am explicitly setting the ID value

How to efficiently test if action is decorated with an attribute (AuthorizeAttribute)?

…衆ロ難τιáo~ 提交于 2021-02-05 20:28:37
问题 I'm using MVC and have a situation where in my OnActionExecuting() I need to determine if the Action method that is about to execute is decorated with an attribute, the AuthorizeAttribute in particular. I'm not asking if authorization succeeded/failed, instead I'm asking does the method require authorization. For non-mvc people filterContext.ActionDescriptor.ActionName is the method name I'm looking for. It is not, however, the currently executing method; rather, it is a method that will be

How to efficiently test if action is decorated with an attribute (AuthorizeAttribute)?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-05 20:27:40
问题 I'm using MVC and have a situation where in my OnActionExecuting() I need to determine if the Action method that is about to execute is decorated with an attribute, the AuthorizeAttribute in particular. I'm not asking if authorization succeeded/failed, instead I'm asking does the method require authorization. For non-mvc people filterContext.ActionDescriptor.ActionName is the method name I'm looking for. It is not, however, the currently executing method; rather, it is a method that will be

How to efficiently test if action is decorated with an attribute (AuthorizeAttribute)?

那年仲夏 提交于 2021-02-05 20:27:38
问题 I'm using MVC and have a situation where in my OnActionExecuting() I need to determine if the Action method that is about to execute is decorated with an attribute, the AuthorizeAttribute in particular. I'm not asking if authorization succeeded/failed, instead I'm asking does the method require authorization. For non-mvc people filterContext.ActionDescriptor.ActionName is the method name I'm looking for. It is not, however, the currently executing method; rather, it is a method that will be

ASP.NET ASP 2 - Prioritize Routing?

喜夏-厌秋 提交于 2021-01-29 03:53:49
问题 For a project, I'm having dynamic pages that are retrieved from a content database. However, some pages require some additional computing. So, I thought I'd create a specific controller/view for those, and they would only be hit when they exist, otherwise, my dynamic route would catch it, and let the content controller retrieve database content for the specified route. I hope I explained it right, but here's some code from my Global.asax that might explain it a bit more: routes.MapRoute( //

ASP.NET ASP 2 - Prioritize Routing?

天涯浪子 提交于 2021-01-29 03:51:13
问题 For a project, I'm having dynamic pages that are retrieved from a content database. However, some pages require some additional computing. So, I thought I'd create a specific controller/view for those, and they would only be hit when they exist, otherwise, my dynamic route would catch it, and let the content controller retrieve database content for the specified route. I hope I explained it right, but here's some code from my Global.asax that might explain it a bit more: routes.MapRoute( //

Stack Trace : at System.Web.HttpServerUtility.ExecuteInternal() || Error executing child request for handler in MVC 2.0

岁酱吖の 提交于 2021-01-27 05:56:06
问题 While Deploying my MVC 2.0 project in to server I'm getting this following error.Locally everything is fine.I want to figure out this error. We have used HttpWebRequest for this functionality. For entire site Glossary search we have created this Control library.Locally the searching is happening but in server empty page is displayed while searching.My file exception show the following error hint. can any one help me pls to figure out this exception.? Date Time : 12/28/2012 11:19:28 AM

Stack Trace : at System.Web.HttpServerUtility.ExecuteInternal() || Error executing child request for handler in MVC 2.0

萝らか妹 提交于 2021-01-27 05:55:18
问题 While Deploying my MVC 2.0 project in to server I'm getting this following error.Locally everything is fine.I want to figure out this error. We have used HttpWebRequest for this functionality. For entire site Glossary search we have created this Control library.Locally the searching is happening but in server empty page is displayed while searching.My file exception show the following error hint. can any one help me pls to figure out this exception.? Date Time : 12/28/2012 11:19:28 AM