Banner 468

Banner 468
Facebook
RSS

Writing your first WCF

What is WCF?

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data. A few sample scenarios include:
  • A secure service to process business transactions.
  • A service that supplies current data to others, such as a traffic report or other monitoring service.
  • A chat service that allows two people to communicate or exchange data in real time.
  • A dashboard application that polls one or more services for data and presents it in a logical presentation.

  • All communication with a Windows Communication Foundation (WCF) service occurs through the endpoints of the service. Endpoints provide clients access to the functionality offered by a WCF service.
  • Each endpoint consists of four properties:
    • An address that indicates where the endpoint can be found.
    • A binding that specifies how a client can communicate with the endpoint.
    • A contract that identifies the operations available.
    • A set of behaviors that specify local implementation details of the endpoint.



[ Read More ]

Implement logging with log4net



Logging errors can be considered a very important part of software development it helps you keep a check on all the run time errors that might arise in our programs

Today i will teach you how to implement logging with the Rolling File Appender in Asp.net

The rolling file appender lets you write errors and comments into a log file plus if the log file exceeds a certain memory limit it will create another one and so on depending on the parameters you have provided.

For using Log4net you will have to download the log4net dll from the internet or you can download directly from the Package Manager Console inside visual studio.

Web.config(Inside Configuration)


  <configSections>
    <section name="log4net"
    type="log4net.Config.Log4NetConfigurationSectionHandler,
log4net"/>
  </configSections>

 <log4net>
    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
      <file value="LogFile.log"/>
      <rollingStyle value="Date"/>
      <datePattern value="yyyyMMdd"/>
      <appendToFile value="true"/>
      <maxSizeRollBackups value="5" />
      <maximumFileSize value="5MB" />
      <countDirection value="1"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%level %logger %date{ISO8601} - %message%newline"/>
      </layout>
      <root>
        <!-- Options are "ALL", "DEBUG", "INFO", "WARN", "ERROR", "FATAL" and "OFF". -->
        <level value="ALL"/>
        <appender-ref ref="RollingFile"/>
      </root>
    </appender>
    </log4net>



By Default we have the following values for following properties of RollingFileAppender
  • staticLogFileName = true
  • countDirection = –1
  • rollingStyle = Composite
  • maxSizeRollBackups = 0 // be careful with this
  • maximumFileSize = “10MB”
  • datePattern = ".yyyy-MM-dd"
staticLogFileName indicates whether you need to keep writing (log) to the same file all the time. You will need to set it to false when using Date as the rolling style and you have large number of backups.
Optionally file.log.yyyy-mm-dd for current formated datePattern can by the currently logging file (or file.log.curSizeRollBackup (rollingStyle=Size) or even file.log.yyyy-mm-dd.curSizeRollBackup --- (rollingStyle=Composite)) This will make time based roll overs with a large number of backups much faster -- it won't have to rename all the backups!
Recommend to leave it at its default value “true”
countDirection when its value is –1, then newest logfile backup will always be file.log.1.. hence this would involve more number of file renaming.
By default newer files have lower numbers. (countDirection < 0) ie. log.1 is most recent, log.5 is the 5th backup, etc... countDirection > 0 does the opposite ie. log.1 is the first backup made, log.5 is the 5th backup made, etc. For infinite backups use countDirection > 0 to reduce rollOver costs.
rollingStyle can be either Date, Size or Composite. the default setting Composite, uses a combination of Size and Date settings. Thus if you have the datePattern set to “.yyyy-MM-dd” and maxSizeRollBackups set to 10, themn it will maintain 10 log backups for each day.


If you have the DatePattern set to “.yyyy-MM-dd HH:mm” and maxSizeRollbackups = 10 then it will maintain 10 logfile backups per minute
[ Read More ]

How to make rounded corners in CSS


This is an example of making rounded corners in CSS and Asp.net do try it

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style>
        .corners{
            color:white;
            border-radius:20px;
            background-color: green;
            height:100px;
            width:100px;
            text-align:left;
        }
    </style>
</head>
<body>
    <div class="corners">
       
    </div>
</body>
</html>
[ Read More ]