Difference between Elmah and Elmah.Contrib.WebApi - asp.net-mvc-4

I am confused between Elmah and Elmah.Contrib.WebApi. And which one is best option for Web API. Iam already using Nlog for exception logging along with Tracing in Web API. So How Elmah is different from all of them. What is the exact need to going for Elmah??
Thanks in Advance

I find that it is useful for catching errors that you did not catch and log yourself. I am using it for a MVC application and it sends me an email when I have an issue that I need to resolve. I can be proactive and I am working on errors before I can hear from the user.

Elmah addresses your default application error logging. However when you're using Web API, for example ASP.NET MVC Web API, you need some extra logic to log your Web API errors within your Elmah data store.
There are a few ways to address this requirement, one being to use the Elmah.Contrib.WebApi package.
Once the package is imported to your project remember to follow any implementation requires, i.e. startup filter registry (as noted here)

Related

.NET Core Fallback Logging

I have two 3rd-party logging providers in my ASP.NET Core GRPC Service. Can I somehow "chain" these logging providers? I mean, can logging provider 2 perform logging only in situations when logging provider 1 failed to log.
For example, if I have an Application Insights provider and NLog File provider, can I log into the file only if my service can't connect to Application Insights infrastructure?
You can do everything mentioned using different NLog targets. So there is a target for Azure Application Insight: https://www.nuget.org/packages/Microsoft.ApplicationInsights.NLogTarget/.
Moreover if you have doubts that some of your targets can proceed slowly you can use asynchronous logging for it: https://github.com/NLog/NLog/wiki/AsyncWrapper-target
In my humble opinion, setting some rule to make 2 kinds of logging providers work like a chain is not necessary and maybe impossible.
What we usually do is making them work at the same time, just like using NLog to write log to files and send log to azure application insights as well.
By the way, azure application insight may not work because of some accident, but it's a small probability event. The scenario that the logging module not working is more likely to be the application crashed, then all the modules in your application are down including both the logging modules. So even have the feature to make Nlog work when application insight doesn't work, it's high probably to have a result that when application insight doesn't work, Nlog can't work too.

ServiceStack WSDL does not include all types

I created a web service within my MVC application. All contracts are using the same namespace. AssemblyInfo.cs also maps the ContractNameSpace with ClrNameSpace.
The generated WSDL does not define my contract types.
This is my second project with ServiceStack. However, the results are different.
Does contracts have to reside in a different assembly in order to ServiceStack to generate WSDL correctly?
The issue was fixed in the latest ServiceStack release: https://github.com/ServiceStack/ServiceStack/issues/306
Make sure you're not using a dodgy tool like WCFStorm. I was getting the same issue even with the current ServiceStack release. I switched to soapUI and everything works expected.
The Types in the WSDLs and XSDs are determined by the Request + Response DTO's used in your services, i.e. they need to be used by your services to be included.
Also be sure to read through the SOAP limitations to make sure there isn't anything you've missed.
If you still think it's an issue, submit an stand-alone project, via gist or pull-request that shows the issue.
Your question is identical to the issue I was having so I'll post my solution here:
I've downloaded the source code and done some investigation on my own. I'm not sure how recent this change is but it appears that in order for your DTO's and Response objects to be included in the wsdl you need to add a query string like "?includeAllTypes=true".
I'm also using the ServiceStack BasicAuthProvider setup which is causing AssignRoles and UnAssignRoles to be added to the Service automatically. The request and response objects for those calls are still failing to make it into the wsdl and causing "Add Service Reference" to fail. Fortunately we aren't making use of them so if I can find another configuration setting to remove them all should be working correctly.

ServiceStack with IIS

I'm trying to publish my website that contains references to servicestack rest APIs.
The Website is fine, but when it tries to access my REST services generated by ServiceStack, it returns 404 errors.
Does anyone know how to publish serviceStack REST services on IIS6?
Thanks
From the instructions on ServiceStack's Hello World tutorial:
Note: due to limitations in IIS 6 - the /custompath must end with
.ashx, e.g: path="servicestack.ashx"
The name can be anything, e.g. it can be api.ashx if you want.
The limitations of handler mappings in ASP.NET/IIS 6 and other possible solutions is explained in this answer.

WCF WSDL Page Missing

I have been following along with the Aaron Skonnard videos on creating a WCF service. I have completed the tutorial found here and when finished the WSDL page that would normally be available to a consumer of this service is not found (page states that "Endpoint is not found").
I have found many references to this issue including adding a 'mex' endpoint, adding httpGetEnabled, etc. but nothing seems to work. I believe this is because the tutorial removes the service files from the website code behind and instead uses a reference to another project.
I like the way the service is created with this tutorial but need to know how to get this WSDL page to display properly so others can consume my service. Is this no longer the correct way to create services in .NET 4?
I don't think REST based services (WebAPI) create a WSDL at all. I beleive the WSDL is only for the SOAP based WCF services.

WCF Data Service - logging and authentication

I'm evaluating the WCF Data Service approach for my next project. As I would need to be flexible on logging and authentication I have a couple of questions that maybe you are able to answer.
1) Am I able to log different level of events, ex. warnings, errors, and redirect them to a different logging sources as database, text file, event log?
2) A link that shows how to perform the requested on question 1
3) Is there a way to introduce a simple authentication based on user name and password and how it is done?
4) Do you have by direct experience discovered any limitation on using Data Services instead of creating a WS-* WCF service for what concerns logging and authentication?
Thanks
There's a good series of blogs about auth over OData service here: http://blogs.msdn.com/b/astoriateam/archive/tags/authentication/
For logging you should be able to use your web server's logging facilities (typically IIS I assume), since all errors are reported as error responses by the service.
You can also override the DataService.HandleException method and implement your own logging in any way you want.
For logging of general non-error things there's also the processing pipeline (DataService.ProcessingPipeline). You can register a handler and implement your own logging of these as well.
I don't know of a sample of this tough.