Click here to Skip to main content
15,903,840 members
Home / Discussions / C#
   

C#

 
AnswerRe: Using a scripting language in a C# exe Pin
BillWoodruff27-Apr-16 20:13
professionalBillWoodruff27-Apr-16 20:13 
GeneralRe: Using a scripting language in a C# exe Pin
Foothill28-Apr-16 3:31
professionalFoothill28-Apr-16 3:31 
QuestionChart Generating Tool Pin
gopichand.n26-Apr-16 23:45
gopichand.n26-Apr-16 23:45 
QuestionRe: Chart Generating Tool Pin
Richard MacCutchan26-Apr-16 23:57
mveRichard MacCutchan26-Apr-16 23:57 
AnswerRe: Chart Generating Tool Pin
gopichand.n27-Apr-16 1:56
gopichand.n27-Apr-16 1:56 
GeneralRe: Chart Generating Tool Pin
Richard MacCutchan27-Apr-16 2:09
mveRichard MacCutchan27-Apr-16 2:09 
GeneralRe: Chart Generating Tool Pin
gopichand.n3-May-16 1:39
gopichand.n3-May-16 1:39 
GeneralRe: Chart Generating Tool Pin
Richard MacCutchan3-May-16 2:34
mveRichard MacCutchan3-May-16 2:34 
QuestionC# Pin
Member 1248659326-Apr-16 7:45
Member 1248659326-Apr-16 7:45 
AnswerRe: C# Pin
OriginalGriff26-Apr-16 8:30
mveOriginalGriff26-Apr-16 8:30 
SuggestionRe: C# Pin
Sascha Lefèvre26-Apr-16 9:23
professionalSascha Lefèvre26-Apr-16 9:23 
GeneralRe: C# Pin
Pete O'Hanlon26-Apr-16 9:31
mvePete O'Hanlon26-Apr-16 9:31 
GeneralRe: C# Pin
Matt T Heffron26-Apr-16 10:22
professionalMatt T Heffron26-Apr-16 10:22 
GeneralRe: C# Pin
Pete O'Hanlon26-Apr-16 10:58
mvePete O'Hanlon26-Apr-16 10:58 
GeneralRe: C# Pin
Sascha Lefèvre26-Apr-16 12:01
professionalSascha Lefèvre26-Apr-16 12:01 
SuggestionRe: C# Pin
Richard Deeming27-Apr-16 1:47
mveRichard Deeming27-Apr-16 1:47 
GeneralRe: C# Pin
Sascha Lefèvre27-Apr-16 1:49
professionalSascha Lefèvre27-Apr-16 1:49 
QuestionCapture exceptions and handle those in my custom error handler Pin
Member 1204569226-Apr-16 5:37
Member 1204569226-Apr-16 5:37 
I have my custom error handler defined in Global.asax:
C#
void Application_Error(Object sender, EventArgs e)
{
    var exception = Server.GetLastError();
    var httpException = exception as HttpException;
    Response.Clear();
    Server.ClearError();

    var routeData = new RouteData();
    routeData.Values["controller"] = "Error";
    routeData.Values["action"] = "General";
    routeData.Values["exception"] = exception;
    Response.StatusCode = 500;

    if(httpException != null)
    {
        Response.StatusCode = httpException.GetHttpCode();
        switch(Response.StatusCode)
        {
            case 403:
                routeData.Values["action"] = "Http403";
                break;
            case 404:
                routeData.Values["action"] = "Http404";
                break;
        }
    }

    IController errorController = new ErrorController();
    var rc = new RequestContext(new HttpContextWrapper(Context), routeData);
    errorController.Execute(rc);

}


Im trying to test my error handler by raising an error like this in my service model:
C#
if(albums != null)
{
    albums = null;
    ctx.SpotifyAlbums.AddRange(albums);
    ctx.SaveChanges();
}


This raises an exception, but how can I "catch" this exception with my custom error handler?
AnswerRe: Capture exceptions and handle those in my custom error handler Pin
Eddy Vluggen26-Apr-16 5:48
professionalEddy Vluggen26-Apr-16 5:48 
QuestionStudent admin management system C# console Pin
Member 1248538426-Apr-16 5:19
Member 1248538426-Apr-16 5:19 
QuestionRe: Student admin management system C# console Pin
Richard MacCutchan26-Apr-16 5:26
mveRichard MacCutchan26-Apr-16 5:26 
AnswerRe: Student admin management system C# console Pin
Eddy Vluggen26-Apr-16 5:55
professionalEddy Vluggen26-Apr-16 5:55 
GeneralRe: Student admin management system C# console Pin
Member 1248538426-Apr-16 7:48
Member 1248538426-Apr-16 7:48 
QuestionRe: Student admin management system C# console Pin
Eddy Vluggen26-Apr-16 8:25
professionalEddy Vluggen26-Apr-16 8:25 
GeneralRe: Student admin management system C# console Pin
Matt T Heffron26-Apr-16 7:54
professionalMatt T Heffron26-Apr-16 7:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.