How to add log tracking system to existing asp.net application - asp.net

Recently I have to maintain multiple existing application that don't have a nice desire Log system.
Most of the time it will be depend on EventLog and it does not perform well if it's front-end issue.
My question is how should I add either Elmah or Log4net to existing project to
with minor effort of changing existing application.
I tried using Log4net before, but seems like to log backend issue, you will need to add in exception from backend code, which will cost alot of effort for my case
Any other tool that provide great looging and minor effort will be appreciated, too

Since both ELMAH and log4net are free tools, you also have the option of using these and logging to a local database, file, or similar. I wrote an eBook about how to do that: .NET Web Application Logging Essentials. If you would like a copy, I can provide you with one by writing me at thomas at elmah.io.
I would also like to mention, that I'm the founder of elmah.io, a cloud-based service for handling exceptions from your web apps. We support both ELMAH and log4net and the installation is extremely easy. It's a paid service, so it's up to you if you can live with the limitations of the free versions.

Related

Debugging Dot Net Website as Domain Normal User

We are developing asp.net website, API and MVC project using Visual Studio. Currently the system we're using are using local administrator account. We are now mapping it to the domain user (normal user). However, certain features are not supported by Visual Studio when we do things like this... importantly..
Debugging applications that a run under a different user account,
such as ASP.NET websites.
Deploying a web application to Internet Information Services (IIS) on a local computer.
Check MSDN Doc here
Note that deploying to IIS is not an issue for us, however the we're unable to debug the application and that is real deal breaker here!
I would like to know how to do debugging for asp.net websites when using domain mapped normal user.
I know this is not a programming related question. However, seems like most of dot net programmers are affected with this and I don't know where to ask for help, so posting it here. (Suggest if any other site is suitable for this!)
Thank you for your help in advance.
The simple answer, as mentioned in that MSDN document and this SO question, is that you can't.
It might be possible to do it through roundabout ways, such as changing the credentials that the IIS worker, application pool, and related processes run as, but even if it were possible, it wouldn't be supported, and most likely wouldn't be worth the effort. Here are two very old articles that deal with the topic:
https://msdn.microsoft.com/en-us/library/aa289173(VS.71).aspx
http://jameskovacs.com/2006/03/16/debugging-as-a-nonadmin/
It may be more feasible if you're able to run your application in an OWIN (Wikipedia) container running in an alternate (to IIS) host.

What are the things missing in Owin/Katana which is available in ASP.NET?

I am looking to build a small ASP.NET application using WebAPI and a html front-end, on .NET 4.0. I need to support authentication, authorization, data access (EF), logging / tracing. It can be an intranet/internet application, so it should support load balancing / clustering.
I am sure if I just go with ASP.NET and IIS I will get all these features. However I like OWINs idea of independent async modules and its goal of being high performance hosting environment. But how much of OWIN/ KATANA is matured and what functionalities are still missing/buggy?
The whole idea of Owin/Katana is to build a light weight server with only the function we need. Your question is better to be "What are things missing in Owin/Katana, which is available in IIS?"
The short answer is, IIS is a full-blown server. Many of the websites we developed only requires a small fraction of all its functions. It is like shipping a bag of grocery using an 18 wheeler.
If you look at Katana, all functions are modular. Say, if I need WebAPI, I can add in that function. When CORS is needed, I will extend appBuilder to the related functions. So in a sense, we have a fully customizable server. Since all functions can be added in, I would say nothing is missing.
Another thing to mention is that an installation of IIS would require you to run a Windows Server. If you are on a Mac or not a server version of Windows, you can host your website on Katana or any other OWIN implementation.

Can I convert a non-MVC asp.net application to be Azure compatible?

Can I convert a non-MVC asp.net application to be Azure compatible ? Or If i want to create an Azure web application, should it be MVC one ?
The other answers answered your question about converting your app to MVC for deployment to Azure (you don't need to).
If you're creating a new web application and go with ASP.NET MVC (which I'd recommend), just remember if you go with MVC3, you may have to make some of the MVC3 DLL's CopyLocal for your deployment, as it won't be part of your web role instance. At least that's how I still understand it. The 1.4 SDK of the Azure SDK doesn't have a MVC3 Web Role template yet.
See this post on steps to get your MVC3 app Azure-ready.
Hope this helps.
You may take a look at the following blog post for migrating an existing ASP.NET application to Azure. It should not necessarily be an ASP.NET MVC application. Any ASP.NET application will work.
azure has 2 roles
1. a webrole
2. worker role
web role is nothing but an asp.net app. so no need to convert it into an MVC app just any asp.net thing will do fine
Yes, you can. But you need to be aware of certain limitations too, none of which were mentioned in the answers already given:
Your application should be stateless, unless you are running a single instance (for most apps 99,9% reliability is OK, but there are some where you want 99,95%, so you need at least two instances + it gives you additional benefits of a load balancer, etc.). The reason for this is that if you have more than one instance, the load balancer will deliver the request to a different instance. You can use AppFabric Cache to solve this.
You don't have a file system - this is not entirely true, but in reality you should never rely on having local files. All you image uploads (e.g. user profile pictures) should be uploaded to a blob storage and linked to there. How you do this is another matter, and one that can be approached differently depending on the architecture of your existing application. You can get away with files, by using Azure Drive, but it's slow as hell.
No Event Log / RDP - this is also only partially true, but you should rely on other ways of getting diagnostics information from your role. While you can RDP to your role instance, there are better ways (e.g. Azure Diagnostics storage).
Database should be chosen carefully. Sure, you have SQL Azure available, but it's expensive (1 GB = 10 USD/ month). If you can get away with stuff like Table Storage, you may save on some costs. Again, this depends a lot on the architecture.
As for the second part of your answer. MVC as a pattern is nice. It saves you a lot of time, it's much more adapt for the Web as WebForms ever will be. The event based system was designed for Desktop applications, and it was forced onto the web. However, going to Azure does not imply a requirement to go to MVC. What I suggest you do however, is treat it as a nice jump-start opportunity to look into MVC and see how it could help you write your apps better & faster.
As with any other case involving architecture of apps, it depends. If you used common patterns (e.g. IOC, Repository), you will have a really easy time moving any app to Azure.

Silverlight/.Net RIA Services - Authorization Working Sample?

I have followed numerous tutorials and walkthroughs/blogs about the capabilities that Ria Services brings to the table when using Silverlight with ASP.Net. Essentially I am looking for a live working example of the authorization functionality that Ria Services can apparently take hold of from ASP.Net. (Even better if it works with ASP.NET MVC too)
Example of failed to work Ria Services authorization implementation
Navigate to the live demo link on this page....fails
This one may work however I couldn't get it to work on my office computer(strange setup that seems to break code for no reason)
Check here: enter link description here. There is a bunch of posts giving samples. It not exactly what you want but has a walk-through for setting up full authorization.
Brad Abrams has some good information. Also note that the new "Silverlight Business Application" template in the Visual Studio -> New Project dialog has authentication set up already where you can mess around with it without having to figure out how to set it up first.
http://blogs.msdn.com/brada/archive/2009/10/05/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-part-26-authentication-and-personalization.aspx
C# Silverlight with RIA Services Authentication
Most likely you haven't configured your environment yet. In the machine.config file for the framework version in use, you will find LocalSqlServer defined. You should edit this definition to point at the SQL Server serving up the aspnetdb database that you want to use (and if you don't have one then start by setting up that).
Machine.config is generally in c:\windows\microsoft.net\framework\v2.something\config
For development you have to configure this in the workstation machine.config to make the debugger's webserver use your production authentication database. For production you have to do the same configuration on the production webserver.
There are different paths for 64 and 32 bit framework instances, and if like me you have 32 and 64 bit editions of version 2, 3, 3.5 and 4 then you have eight "root" configuration files. If you hunt them all down and set all of them it will save untold confusion later.
This is from my blog last october:
The Business Application Template for Silverlight comes with a login and register pages. It is very easy to connect these to a ASPNETDB.mdf.
Just add a LocalSqlServer connection string to your web.config file. For example, here is what I use to connect to Sql Server.
It’s almost too easy!
If you are using SqlExpress on your dev machine, it gets even easier. You don’t have to do anything. Just create a new Silverlight Business App and fire it up. Go to the log-on page and register. It will be slow, but in the background, your ASPNETDB was just created and attached, and you will be logged in. If you then look in the Web.config file, you won’t see a connection string anywhere, as the defaults are used for this piece of magic. Of course, a real world connection is going to need it’s own connection string like the above.
Greg

Asp.net Deployment (web installer)

I need to implement a web site installer for my asp.net application. The installer will be handling following features -
Deploy the .net web application on to the IIS server
Setting up the Sql database connection to run the DB scripts.
Execute all the DB scripts.
Run another exe for the license management.
If some thing goes wrong, need to rollback everything.
I have heard about wix and install shield and wondering what would be the best technology suitable for this particular case.
Thanks Thurein
MSDeploy does all this and more. Find it over on www.iis.net.
-Oisin
WIX has the advantage of being very flexible and free. It also has a somewhat steep learning curve. If you are going to be doing something like this frequently however, it is certainly worth the investment.
After that, there are any number of commercial options to choose from, i.e InstallShield.

Resources