MVC :: Add Global Filter Only On Debug?
Feb 11, 2011I am adding a global action filter on a MVC 3 project.
How can I make it being added on debug but not on release?
I am adding a global action filter on a MVC 3 project.
How can I make it being added on debug but not on release?
i have written in the "Application_BeginRequest" Method that the header of every HTTP Request will be analyzed.
It only works when i visit the myip/default.aspx site. But when i want to visit any other site there will be no entry in the database or in the listbox (the listbox is only for me to see what happens)It runs on an IIS 5.1.
I also changed in the IIS Settings the ASP.NET from 2.0 to 4.0. Do i need to configure the IIS 5.1 to use the global.asax.cs on every url?
I thought the global.asax.cs runs on every site on the webserver.
[code]....
Not using Cassini, but IIS7 to run an ASP.NET app.
The debug behavior is flakey. Sometimes it works, sometimes it doesn't. I was able to step into the application start event in global.asax but sometimes I can't.
Sometimes VS2008 opens the published global.asax so I have two instances of global.asax opened in VS, the source and the published.
I reset the AppDomain and IIS and I can't put my finger on why this is happening.
To add, while it won't go into application start, I have an OnChangeEventHandler event - it does step into the event handler.
I have tried everything, even uninstalling asp.net mvc3, and I can't get HandleError global filter working.I have set up the HandleError filter in the Global.asax:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
Also I have CustomErrors enabled (it does not matter if i set defaultRedirect="Error" or not, I think that is in the docs because is needed for older versions of mvc):
<customErrors mode="On" />
Trying to navigate through the page until the error gets raised, wether you do from localhost or using the hostname, inside the development server or IIS 7.5, it always redirects to a standard status 500 page, instead of my custom Error.cshtml view that I have created in Shared. Here is Error view code:
@model System.Web.Mvc.HandleErrorInfo
@{
ViewBag.Title = "Oooops";
}
<h2>Ooops Something really bad happened!</h2>
Also I have noted that if I create a new ASP.NET MVC3 project and then select "Internet Application" template, and just enabling customErrors in that project, then the HandleError filter starts working just fine, however using the empty MVC3 template does not.I want to clarify, that indeed I can see the error view being processing when debugging, however the browser always display Error 500 page.
I have not found any way to intercept or override calls to createquery in my datacontext. What I am trying to do is to allow for global filters, i.e. if a user has access to only a subset of entities I would like to filter away these on the lowest level possible. Is there a way to do this? I have tried several apporaches but no one worked out. Perhaps I lack patience or is just plain stupid, but I think it should be possible! So if anyone has any pointers to where
View 2 RepliesI want to debug EditPanel.debug.js file of HTML Editor, but it never shows in VS 08 and Im sure it executes to that line.What I did to enable debuggingUnchecked both 2 checkboxes for disabling the debugging
Set ScriptMode="Debug"
Change following line
[ClientScriptResource("AjaxControlToolkit.HTMLEditor.EditPanel", "AjaxControlToolkit.HTMLEditor.EditPanel.js")]
to
[ClientScriptResource("AjaxControlToolkit.HTMLEditor.EditPanel", "AjaxControlToolkit.HTMLEditor.EditPanel.debug.js")]
On my web form, I have a RadioButtonList nested within a ListView as follows:
Nested RadioButtonList, and Inconsistency between Debug and Run without Debug
Debug-Start Debugging/Debug-StartWithoutDebugging OR Project ASP.Net Configuration launches Dreamweaver. It started lastnight, I had both Deamweaver and VWD 2008 express open at the same time - (I was looking at JQuery in the Microsoft and Dreamweaver enviroments simultaniously). After the first tie this happened, I closed down Dreamweaver (CS3) and it opened when I tried to run my VWD project. I reinstalled VWD 2008 express, IIS and disabled Dreamweaver (renamed the exe). Dreamweaver still came up.
View 4 RepliesI know there is a couple answered questions on here regarding "request scoped" globals, but I want to nit-pick on something specifically and maybe squeeze some extra enlightenment out of one or two of you.I have an ASP.NET C# Website and a static Dictionary of objects (loaded from DB once on Application start). Each page request will need to do a lookup in the Dictionary (based on a key derived from the request url/etc) and get the appropriate object.The issue is I'm trying to maximize efficiency by reducing the lookups to the Dictionary per Request. Doing just a single lookup within a Page itself is easy enough and I can pass the object to sub controls, etc too.. but global.asax is separate from the Page and it also needs to use the object (in Application_BeginRequest and Session_Start).
So is doing a Dictionary lookup once in Application_BeginRequest, once (when necessary) in Session_Start and once in the Page negligible speed wise, even if there are many requests coming in every second?I would like it if I could just have a Request scoped global variable that I can easily call upon.. the only one I see available though is HttpContext.Current.Items and that is a Dictionary itself.Am I beingridiculously nit-picky with my concern over efficiency? or will these milliseconds (nanoseconds?) get me in the long run when more and more requests are being made?
PS. I currently only have around 100 objects in the Dictionary although this may increase in the future.
I need good css for Gridview just like the mac css
can we provide the filter functionality to gridview like the excel filter.
In securing actions/controllers, do I have to create a custom filter or use MVC built-in filter?
To use the built-in attribute Authorize() on an action/controller or create a separate class that inherits the ActionFilterAttribute which has a method (OnActionExecuting) to override and do the authentication there?
In my organization we use nested groups. For a particular usage, we have a group (let's assume that the group name "kuku"), and the names of all the nested groups under it contains "kuku" as well.
We may assume that no other group in the LDAP has "kuku" in the name.
I need to create a filter which will return all the users which belong to one of the "kuku"s group.
Obviously, using this filter will bring only the head kukus
(&(&(objectclass=user)(objectclass=person))(memberOf=CN=kuku,cn=...rest of the group DN...))
How can I use wild card to fetch all users which belong to any kuku?
For example: (&(&(objectclass=user)(objectclass=person))(memberOf=CN=.*kuku.*))
I have decorated my base controller with a couple of action filters. They work fine.
One of those filters sets up the request - does things like set the culture based on the domain, etc.
I also have a handful of actions that require authorization using the Authorize attribute.
My problem is that when an user attempts to request a page they are not authorized to access, the authorization filter kicks in and redirects them to a page telling them that they cannot vie the page.
The issue is that the action filters never run so the culture and other request data is never set. This effectively causes language to be wrong in the view and other data to be missing.
I know that authorization filters run first but my question is this: How can I design this such that I can ensure that certain methods are always run before the view is returned, regardless of the authorization.
does a action filter override a controller filter?
View 2 RepliesIn Many Interview they have asked me that.
How would u debug web application in .net?
I Say the using F10, F11 but this is not the correct answer.
can i register a debug logger that outputs information to the 'standard ASP.NET debug window'. My problem is I don't know what that means, if it means the debug output window in Visual Studio (where you see build output, debug output and more) I am not seeing any UrlRewriter debug output. The rules are working (mostly) I just want to get more debug output to fix issues. I added the register call to the rewriter section like this:
<rewriter>
<register logger="Intelligencia.UrlRewriter.Logging.DebugLogger, Intelligencia.UrlRewriter" />
....
</rewriter>
I am hosting this website locally in IIS on Vista, to debug it I attach the debugger to the w3wp process. Other selected parts from the web.config"
<compilation debug="true">
<assemblies>
...
</assemblies>
</compilation>
<trace enabled="true"/>
Where should I see the debug output from UrlRewriter.NET? If it is in the Visual Studio debug output window, any ideas why I am not seeing it there?
What are the steps to debug a new class in VS.Net?
View 4 RepliesI have an ASP.NET C# project consuming webservices and WebMethods are wrote in VB.NET with source code on a local IIS server. The WebMethod returns null, and I want to debug it to know why I get this.
if I set a breakpoint just before the webmethod call, I cant step into this webmethod.
So, how is the correct way to debug this webmethod?
I have been asked to work of a very large web application and deploy it. The problem that I'm facing here is that when I deploy the application and more that 1 user logs into the system, the sessions seem to cross over i.e: Person A logs in and works on the site, all good. When person B logs in, person A will then be logged in as person B as well.
I have been asked to work of a very large web application and deploy it. The problem that I'm facing here is that when I deploy the application and more that 1 user logs into the system, the sessions seem to cross over i.e: Person A logs in and works on the site, all good. When person B logs in, person A will then be logged in as person B as well.
If anyone has experienced this behaviour before and can steer me in the right direction, that would be first prize, Second prize would be to show me how I can debug this situation so that I can find out where the problem is and fix it.Some information about the application. From what I've been told and what I've seen within the app is that it started as a .Net 1.1 application and got upgraded to .Net 2 and that's why the log in system was done the way it is. (The application is huge and now complete and that's why I cant rewrite the whole user authentication process, it will just take to long and I don't know what effect it might have)
All the Logged in User information is stored in properties that have been added in the Global.asax.vb file. (could this be the problem?)
why is it that when i debug my application in chrome it is relatively slow between postbacks compared to internet explorer? when i use internet explorer, its lightning fast.
View 6 RepliesI hosted web Application on my machine. And my co-workers are connecting to the site by opening website through FTP. I can debug with no issue. But my-coworkers can't debug since they connected through FTP. Is there any work-around to debug FTP site?
View 6 RepliesI've developed a fairly simple web service which receives an xml string, validates it and passes it on to our internal database. This has been written to enable one of our clients to send us idocs from their SAP system. The trouble is that, although the web service works fine from a .net program, over the internet, the client's SAP system can't access it. They either get just an http 200 back (rather than the status code that the web service should supply) or they get http 500 'Internal Server Error'. I was wondering if anyone else has had issue's with ASP.NET web services from non 1qs`asp.net applications, or whether anyone can give me any advice on debugging http 500 errors.
View 4 RepliesI have few confusions about build. What is release build and debug build? What are the output files for these builds? I had seen debug and release folders in bin folder. So the respective output goes into the respective folder? elaborate release and debug build. I dont want the difference.
View 3 RepliesI can't get to the breakpoint in the cobebehind file, the debug is enabled in web config and project properties.
View 3 RepliesI am currently developing a silverlight application, however yesterday I started getting the following error message every time I run the project:
If I click "yes" to debug - nothing happens. Also, I have no Line 1805 in any of my source files!
This error message started appearing yesterday, and appears as soon as I run the project, shortly before the first page loads. If i click yes or no, the project then loads and runs perfectly, I cannot see any unwanted behaviour.
I have been using source control, so I rolled back the project to a point before the error started appearing, however I am still getting the error!
Could it be a setting in VS Web Developer Express 2010 that I have accidentally changed?