Combine MVCContrib's "Rescue" With Elmah?

Mar 22, 2010

I got the Rescue attribute working. It properly serves up the DefaultError view when there is an unhandled exception.

However, these exceptions will not get logged or emailed. This SO question is answered by Atif Aziz and it looks pretty solid, but it applies to the built-in HandleErrorAttribute, which Rescue replaces, right? How do I get that to work with Rescue? I want to make sure that if an unhandled exception arises, that the user gets served up the view specified with the Rescue attribute, but the exception is still properly logged, and viewable with elmah.axd.

Update:

var currentContext = HttpContext.Current;
Elmah.ErrorSignal.FromContext(currentContext).Raise(ViewData.Model.Exception, currentContext);

I added the above to my view and it properly logs and emails errors now. However, it doesn't seem like doing this in the view is the right thing.

View 1 Replies


Similar Messages:

How To Use MvcContrib Template Gallery For Mvc

Aug 25, 2010

Has any one ever downloaded and made use of the mvcContrib template gallery for asp.net mvc. I cant find where to download the templates from and there is no documentation for how to use it?

View 1 Replies

MVC :: Latest Version Of T4MVC But Without MVCContrib?

Mar 9, 2010

Isn't possible to get the latest version of T4MVC without MVCContrib?

If yes where can I find it?

View 1 Replies

MvcContrib - Get Area Into MenuBuilder ActionLink?

Jan 12, 2011

I am using MenuBuilder with code like this:

public static MenuItem MainMenu(UrlHelper url)
{
Menu.DefaultIconDirectory = url.Content("~/Public/Images/");
Menu.DefaultDisabledClass = "disabled";
Menu.DefaultSelectedClass = "current";
return Menu.Begin(
Menu.Items("",
Menu.Action<HomeController>(p => p.Index(), "Home")
),
Menu.Items("",
Menu.Secure<HomeController>(p => p.About(), "About")
),
Menu.Items("",
Menu.Action<RegulationController>(p => p.Index(null), "Compliance")
)/* This is in the Compliance area */
).SetListClass("menu");
}

But I am also using MvcContib Areas and in the code above the final menu item is in an 'Area' called 'Compliance'.

(There are two other areas in the Mvc application and the first in the list of registered areas is called 'Legislation')

What happens is the following:

When a page is rendered (I am using the standard WebFormsViewEngine) the Urls are all rendered using the 'Legislation' area!!?

E.g. http://localhost:1337/Legislation/Home or http://localhost:1337/Legislation/Home/About

and finally http://localhost:1337/Legislation/Regulation

The first two links should not pick up the 'Legislation' area. The last menu item should be in the 'Compliance' area.

How do I prevent the erroneous Area (Legislation) being rendered on the first two links?

How do I get the MenuBuilder markup in the Site.Master to accept an 'area' attribute or get it picked up automatically from the Controller for each link?

View 1 Replies

MVC :: Sorting In Mvccontrib Html.grid In Application

Feb 2, 2011

I have done listing by using html.grid in my mvc application, need to do sorting How can i do that

View 4 Replies

MVC :: Security Exception When Using MVCcontrib Grid On Server

Jun 21, 2010

I am using MVCcontrib grid in my application. Everything works fine on my dev machine. When I publish it to the server and navigate to the page that renders the grid I am getting this error Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. and the source of the error is shown as <%= Html.Grid(Model).Columns(column => {i have added

[Code]....

to the web.config but still&nbsp;get the error&nbsp;

&nbsp;
</textarea></p>
<input type='hidden' name='ID[9]' value='93970' />
<input type='hidden' name='URL[9]' value=[URL]/>
<input type='hidden' name='CAT[9]' value='DataSource Controls' />
<input type='hidden' name='BOARD[9]' value='microsoft' />
<input type='hidden' name='P_DATE[9]' value='Jan 12, 2010 09:43 PM' />
<input type='hidden' name='RANDOM[9]' value='BcIlUOXzN' />
<input type='hidden' name='REPLIES[9]' value='3' />
<input type='hidden' name='USER[9]' value='aziz' />
<p><input class=subject type='text' size='90' name='SUBJECT[9]' value='DataSource Controls :: LINQ using stored procedures and MvcContrib Grid with pagination' /><select name='INDEXED[9]'><option value='1' selected>UPDATE</option><option value='2'>DELETE</option></select>Jan 12, 2010 09:43 PM - Replies: 3 CAT: DataSource Controls<a target=_blank href=[URL]>View</a></p>
<p> <textarea rows=10 cols=100 name='POST[9]' onfocus='setSelRange(this, 0, 0)'/>All,

I have been chasing this erorr all day and coming up blank.&nbsp; I created a stored proceudre(fairly complicated logic), added it to the context, and set the return type to a specific entity type.

It generated this:

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
[Function(Name="dbo.usp_ServiceTemplateSelectByFkID")]
public ISingleResult<ServiceTemplate> usp_ServiceTemplateSelectByFkID([Parameter(Name="FkId", DbType="Int")] System.Nullable<int> FkId)
{
&nbsp;&nbsp;&nbsp; IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), FkId);
&nbsp;&nbsp;&nbsp; return ((ISingleResult<ServiceTemplate>)(result.ReturnValue));
}

I call it from my service with the following method:

public ISingleResult<ServiceTemplate> GetByFkId(int FkId)
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return Db.usp_ServiceTemplateSelectByFkId(FkId);
}

I have tested the stored procedure and it returns the results I want.&nbsp; When I make the service call from the controller, it doesn't error out, however, it should return 4 records in this instance and instead, it returns the same 4 records (repeating the first record 4 times).&nbsp;.........

View 4 Replies

MVC :: How To Add Maxlength Attribute To MVCContrib Grid Column

Nov 16, 2010

i am working in mvc & using MVCContrib grid to show result in grid format.

I want to add restriction to 1 of the grid columns as not to accept more than 3 characters.

how can i add "maxlength" attribute to MVC Contrib grid column.

Or if any other way

View 1 Replies

MVC :: Testing Routes With MvcContrib.TestHelper And MsUnit?

May 8, 2010

I'm trying to get my route tests going using MvcContrib.TestHelper and MsUnit. This is what I got: (Pretty much straight out of MVC 2 in Action, Chapter 26, Testing Practices. Just I *have* to use msUnit, while the book use nUnit)

[Code]....

However I get an error saying : MvcContribTestHelperSandbox.Tests.Controllers.RouteTests.Setup has wrong signature. The method should be marked .. [rest is just cut off...not nice!) When I tried runnig it without the setup, I get some error complaining about a wrong version of Rhino Mocks, which I'm not even using! (Intend to add a reference to Moq.dll when I need to do mocking)

View 3 Replies

Overriding The Default 'No Data' Message In MVCContrib Grid?

Oct 21, 2010

Is it possible to override the default 'There is no Data available' message in MVCContrib Grid with a custom message?

View 1 Replies

Auto Generate Grid Using Mvccontrib By Passing Datatable In MVC 2 Application

Jul 6, 2010

In My project i want to use the mvccontrib [URL] to auto generate grid by passing the DataTable to the Grid. Currently Grid does not support this. Grid takes IEnumerable(Of T) and auto generate columns. Is their any way i can achieve this by passing DataTable. Or How do i convert the DataTable to IEnumerable(Of T). My DataTable is completely Dynamic i don't know number of columns or names of the columns at design time. DataTable completely dynamic number of columns are not fixed it just any DataTable. In Short i want to convert Dynamic DataTable to IEnumerable(Of T). Or Is their any better way.

1) One way i tried is using .net 4.0 Dynamic, DynamicObject and ExpandoObject I created a dynamic class as shown here [URL]. I trid passing IEnumerable(Of SampleDynamicObject) but BuildColumns() method is not able to find out the proprieties dynamically added on to it.

2) I think Second way to modify the AutoGenerateColumns() method to work with DataTable, But it looks impossible as Grid Get initialize using IEnumerable(Of T) and all the call on grid for method is using IEnumerable(Of T). So it's come down to converting DataTable to IEnumerable(Of T) and my DataTable are dynamic i don't know their structure at design time So i can't write any specific class to create a object and convert DataTable to IEnumerable(Of T).

View 1 Replies

C# - Test A MVC2 Post Action With Validation When Using MvcContrib TestHelper?

Oct 12, 2010

I'm attempting to write a unit tests for an ASP.NET MVC 2 post action that takes a view model as its sole parameter. The view model is decorated with validation attributes such as [Required]. I'd like to test two scenarios. The first scenario is when a valid set of data is passed in (ie, all required properties have values) and a redirect to the list page is returned. The second scenario involves passing in invalid data (eg, when one or more of the Required properties are not set). In this case the same view is returned with error messages.The action signature is as follows:

[HttpPost]
public virtual ActionResult Create(NewsViewModel model)

The NewsViewModel class is as follows:

public class NewsViewModel
{
public Guid Id { get; set; }

[code]...

View 1 Replies

DataSource Controls :: LINQ Using Stored Procedures And MvcContrib Grid With Pagination?

Jan 12, 2010

I have been chasing this erorr all day and coming up blank. I created a stored proceudre(fairly complicated logic), added it to the context, and set the return type to a specific entity type.

It generated this:

[Function(Name="dbo.usp_ServiceTemplateSelectByFkID")]
public ISingleResult<ServiceTemplate> usp_ServiceTemplateSelectByFkID([Parameter(Name="FkId", DbType="Int")] System.Nullable<int> FkId)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), FkId);
return ((ISingleResult<ServiceTemplate>)(result.ReturnValue));
}

I call it from my service with the following method:

public ISingleResult<ServiceTemplate> GetByFkId(int FkId)
{
return Db.usp_ServiceTemplateSelectByFkId(FkId);
}

I have tested the stored procedure and it returns the results I want. When I make the service call from the controller, it doesn't error out, however, it should return 4 records in this instance and instead, it returns the same 4 records (repeating the first record 4 times).

In addition, in my controller code, I am using the MVCContrib ToPagedList() method which doesn't appear to work with the ISingleResult interface (forward only cursor, I'm guessing). I have attempted converting the service results to IQuery, List, and Array, however, I still have the problem with the first record being repeated 4 times.

View 3 Replies

Mvccontrib Test Helper And Verifying Http Post Routes And Parameters?

Jan 29, 2010

In my Asp.net MVC app, I have two methods on a controller, one for when the user first arrives on the view and then one when they submit the form on said view.

public ActionResult Foo() {}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Foo(string id, Account accountToFoo) {}

In the second action, there's a custom model binder that's assembling the account object that I'm acting on, though that's really not important. This all works fine in testing locally on a server.We try to be pretty good about writing unit tests to test all our different views are properly getting routed to, including those that are HTTP POST. To do so, we've been using mvccontrib's test helper.

Testing gets have been super simple

"~/account/foo/myusername".
Route().
ShouldMapTo<AccountController>(c => c.Foo("myusername"));

My question is in testing POST routes, how do I write the lambda that I would use to verify the post is receiving accurate values, similar to the GET test above?

For a POST, it looks something like:

"~/account/foo".
WithMethod(HttpVerbs.Post).
ShouldMapTo<AccountController>(a => something_something);

It's the something_something portion of my lambda that I'm having trouble with. Using arbitrary values doesn't work ("a => a.Foo(0, new Account()"). How would I specify the expected values as part of the test?EDIT I was hoping there was something akin to the way Moq has lambdas for statements such as foo.Setup(s => s.Foo(It.IsAny(), It.Is(i => i > 32)) and so on. Even I have to explicitly supply the values, that's workable--I just can't seem to grok the desired structure to pass those explicit values.

View 2 Replies

C# - Using ELMAH With Areas In MVC 2?

Jan 24, 2011

I'm following this blog post about setting up ELMAH with MVC: [URL] I've only done part 1. Everything works correctly if I simply go to the Home controller, and then cause an error. I can view /elmah.axd as well, and my errors are logging in the database correctly.

However, I've added an area to my application named Admin. If I navigate to /Admin, I receive the following error:

System.MissingMethodException: No parameterless constructor defined for this object.
public override IController CreateController(RequestContext requestContext, string controllerName)
{
var controller = base.CreateController(requestContext, controllerName); //Error here
var c = controller as Controller;

I'm assuming this has something to do with my Area.

EDIT for jfar:

For instance, I have an Employees controller in my Admin area:

public class EmployeesController : Controller
{
private IEmployeesRepository employeesRepository;
public EmployeesController(IEmployeesRepository employeesRepository)
{
this.employeesRepository = employeesRepository;
}
//...
}

View 1 Replies

How To Setup Elmah

May 21, 2010

I am trying to setup elmah for asp.net 1.1 application.i have following entry in my web.config

<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>

[code]...

View 2 Replies

C# - Using ELMAH And URLRewritingNet Together?

Feb 24, 2010

I have ELMAH setup on my production server and it has done a fantastic job of letting me know about any niggles - as well as any creative SQL injection!I've decided to introduce URl Rewriting and went for http://www.urlrewriting.net/ in the end. It was nice and easy to setup and it's doing exactly what I want with the customer-facing site.The problem is ELMAH. Because I've set the urlrewritingnet node in my config like so:

<urlrewritingnet
rewriteOnlyVirtualUrls="true"
contextItemsPrefix="QueryString"

[code]...

View 2 Replies

How To Configure ELMAH Programmatically

May 7, 2010

I'm interested in using ELMAH but need to configure it programmatically. We have existing infrastructure for determining connection strings and the like, and can't code them into Web.Config.How do I go about using ELMAH in this case?

View 1 Replies

Is It Possible To Configure ELMAH Entirely In Code

Jun 22, 2010

I'd like to configure ELMAH for an ASP.NET MVC site entirely in code. This includes registering the module, setting the logging provider and settings, and filtering exceptions.The only part I've managed to do so far is filter exceptions. Has anyone else figured out how to do this? I'd really like to avoid cluttering up my config file with settings that won't ever change.

View 2 Replies

How To Get ELMAH To Throw Its Own Exceptions

Aug 3, 2010

There used to be an article at ELMAHs docs site that contained this information, but it seems to have been removed. I think it's as simple as setting a configuration setting in the section, but I haven't a clue what it isCan anyone take a few seconds and drop the configuration setting here?

View 1 Replies

Elmah And Network Cards?

Dec 1, 2010

I am using Elmah in one of our production deployments and would like to secure the module to the local network only and not expose it to the public. I am aware of the remote logging option that can be turned off and also asp.net authorization, however I am interested to know if there is any support in Elmah's configuration to bind to a secondary NIC/network card which only faces the internal network ?

View 1 Replies

Use ELMAH To Log Database Errors?

Mar 5, 2010

I'm using ELMAH to handle the exceptions in my ASP.Net MVC project. I would like to use it to log errors like database connection timeout, query connection timeout and others. Is this possible with ELMAH?

View 2 Replies

C# - Elmah Is Only Logging 15 Errors?

Jun 10, 2010

I've just starting looking at a site in place at work. They're using Elmah to log errors.It seems to be logging fine, but in the web interface, when I tell Elmah to show me 100 errors per page, it only shows the most recent 15.Then when I click on "Download Log" I only get shown 15 errors in the CSV.Anyone know how I can configure it to keep all the errors?Or can someone point me to some docs on how to do this?

View 2 Replies

C# - Determine Whether Or Not ELMAH Is Enabled?

Jan 31, 2010

How can I determine programmatically whether or not ELMAH is enabled?

View 2 Replies

C# - ELMAH Not Logging Errors In MVC 2 App?

Feb 3, 2011

I'm using the suggestion from this question: How to get ELMAH to work with ASP.NET MVC [HandleError] attribute?I used Aziz's second code sample.I ran the debugger to see what happens when an error occurs. The main function in the HandleErrorAttribute class is:

public override void OnException(ExceptionContext context)
{
base.OnException(context);

[code]...

View 3 Replies

C# - Elmah: Exceptions Without HttpContext?

Jan 21, 2010

I spawn a thread on Application_Start and would like to log exceptions. There is not Context/HttpContext/HttpContext.Current, so how might i get it to log?ATM it does not catch any exception in my threads and if i write ErrorSignal.FromCurrentContext().Raise(ex); i get an error about context cannot be null.Maybe i can create a dummy HttpContext but somehow i dont think that will work well.-edit- i tried ErrorSignal.Get(new HttpApplication()).Raise(ex); and it doesnt seem to pick up that exception.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved