Archive

Archive for the ‘ASP.NET’ Category

Client Certificate from the User Store to the Local Machine Store

August 18th, 2010 1 comment

If a service application such as ASP.NET Web application cannot access a client certificate that other applications like console applications can access, then the client certificate may not be stored in the local machine. You can understand that something like that may be happening if you get the error:

Could not create SSL/TLS secure channel for your Web Request and you can’t understand what is going wrong while it might be ok at your development machine but when you try to publish it you get this error.

So let’s copy a client certificate in the local user store to the local machine store by using the Certificate Export Wizard following the steps below:

  1. Click Start, click Run, type mmc, and then click OK.
  2. On the File menu, click Add/Remove Snap-in, and then click Add.
  3. In the Add Standalone Snap-ins dialog box, click Certificates, click Add, click Computer account, click Next, and then click Finish.
    image
  4. In the Add Standalone Snap-ins dialog box, click Certificates, click Add, click My user account, and then click Finish.
    image image
  5. Click Close, and then click OK.
    image
  6. To export the client certificate from the local user store, follow these steps:
    1. Expand Certificates – Current User, expand Personal, and then click Certificates.
      image
    2. Right-click the client certificate, click All Tasks, click Export, and then click Next.
      image
    3. Click Yes, export the private key, and then click Next two times.
      image image
    4. In the Password box and in the Confirm Password box, type a password, and then click Next.
      image
    5. In the File name box, type a file name. Click Next, and then click Finish.
      image
    6. In the Certificate Export Wizard dialog box, click OK.
      image
  7. To import the client certificate to the local machine store, follow these steps:
    1. Expand Certificates (Local Computer), and then expand Personal.
      image
    2. Right-click Certificates, click All Task, click Import, and then click Next.
      image
    3. In the File name box, type the file name that you specified in step 6e, and then click Next.
      image
    4. In the Password box, type the password that you specified in step 6d, and then click Next two times.
      image image
    5. Click Finish, and then click OK.
      image
Categories: ASP.NET Tags: ,

ASP.NET validators and javascript can do beautiful things…

March 31st, 2010 4 comments

Here is a small recipe about making some things a little more beautiful using asp.net Validators and some javascript.

What do we need:

  • ASP.NET Validators like RequiredFieldValidator
  • jQuery
  • jQuery Tooltip
  • A nice tooltip image and some css

Read more…

Categories: ASP.NET Tags: , ,

Asp.net handlers and IRequiresSessionState

March 22nd, 2010 No comments

This is a small one :)

By default when you create a new asp.net handler (.ashx) it implements the interface IHttpHandler. If you want to access information about user and other things stored in session you need also to implement the IRequiresSessionState.

IRequiresSessionState specifies that the target HTTP handler requires read and write access to session-state values

Categories: ASP.NET Tags: ,

ASP.NET How to Change web.config In Order To Upload Bigger Files

January 11th, 2010 No comments

When you want to upload files using FileUpload and asp.net you have a limit of  4 MB per request.

This is the default maximum file size set in machine.config. In order to change that and expand the upload limit to 10MB,  you need to override it in web.config.

<system.web>
  <httpRuntime executionTimeout="240" maxRequestLength="10240" />
</system.web>

Most of the times you want to upload a big file in a specific folder and not your whole website, take for example the Uploads folder where you usually store images, video, audio. In order to do this you can use the location tag. An example is the following:

<location path="Uploads">
    <system.web>
        <httpRuntime executionTimeout="110" maxRequestLength="10240" />
    </system.web>
</location>

The full list of properties is shown on the following example:

<httpRuntime
 executionTimeout="110"
 maxRequestLength="10240"
 requestLengthDiskThreshold="80"
 useFullyQualifiedRedirectUrl="false"
 minFreeThreads="8"
 minLocalRequestFreeThreads="4"
 appRequestQueueLimit="5000"
 enableKernelOutputCache="true"
 enableVersionHeader="true"
 requireRootedSaveAsPath="true"
 enable="true"
 shutdownTimeout="90"
 delayNotificationTimeout="5"
 waitChangeNotification="0"
 maxWaitChangeNotification="0"
 enableHeaderChecking="true"
 sendCacheControlHeader="true"
 apartmentThreading="false" />
Categories: ASP.NET Tags: ,

How to Create an Event in ASP.NET User Control

October 26th, 2009 No comments

Let’s assume we have a control ShippingSelect.ascx and we would like to assign an event like ItemCommand.

Firstly we add a new User Control to our project (ShippingSelect.ascx) and at the code behind we need to declare the name of the event using the EventHandler<TEventArgs> where TEventArgs is an EventArgs that contains the event data.

Read more…

Categories: ASP.NET Tags: ,