.Net "Specified method is not supported." Error

by nolovelust 20. April 2011 16:13

I started to get this "Specified method is not supported." error quite a lot since I moved one of the sites to Windows 2008 R2 64bit.

Exact error something like below

 

 

Server Error in '/' Application.
Specified method is not supported. 
 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.NotSupportedException: Specified method is not supported.

Source Error: 
 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 


Stack Trace: 

[NotSupportedException: Specified method is not supported.]
   System.Web.HttpResponseStream.get_Position() +29
   System.Drawing.ComStreamFromDataStream.Seek(Int64 offset, Int32 origin) +44

[HttpException (0x80004005): An error occurred while communicating with the remote host. The error code is 0x800703E3.]
   System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect) +3049599
   System.Web.Hosting.IIS7WorkerRequest.ReadEntityCoreSync(Byte[] buffer, Int32 offset, Int32 size) +49
   System.Web.Hosting.IIS7WorkerRequest.ReadEntityBody(Byte[] buffer, Int32 size) +23
   System.Web.HttpRequest.GetEntireRawContent() +8920994
   System.Web.HttpRequest.GetMultipartContent() +68
   System.Web.HttpRequest.FillInFormCollection() +172
   System.Web.HttpRequest.get_Form() +68
   System.Web.HttpRequest.get_HasForm() +8921807
   System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97
   System.Web.UI.Page.DeterminePostBackMode() +69
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +135



Above sample from a page where user submits multipart form data.

Same eror happens when user downlods file from a HttpHandler.

Actual error is quite confusing and as far as i understand it has nothing to do with System.Drawing but client disconnect during to upload proccess.

There is a bug report about I couldn't get any more info.

I have seen no side effects of this error and can say simply igonoring it is the current solution :)

Tags: , ,

ASP.NET | Useful

mobile geolocation with jquery and google maps api and asp.net c#

by nolovelust 13. December 2010 09:38

Below code uses google maps api with local proxy code to get country,city and local area of user. Fully functuional apart from multiple entries not being filtered in the result. I'll hopefully fix it too.

It only workd phones that support navigator.geolocation such as iPhone, webOs, Android, Nokia N900

Due to same origin policy I've had to use local proxy code to download location data from google (see below)

 

To run the code create an html file and paste below code on to it 

<script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
         function find() {
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(success, error);
            } 
            else if ( window.google && google.gears ) {
            var geo = google.gears.factory.create( 'beta.geolocation' );
            geo.getCurrentPosition(success, error);
          }
          else {
                $('#output').html('Not supported');
            }
        }
        function success(position) {
            var lat = position.coords.latitude;
            var long = position.coords.longitude;
            var pullurl = 'getLocationResponse.ashx?latlng=' + lat + ',' + long;
            get(pullurl);
            //$('#output').html(pullurl);
        }
        function error(msg) {
            $('#output').html('failed to get coordinates');
        }
        function get(url) {
            $.ajax({
                type: "GET",
                url: url,
                dataType: "xml",
                success: parseXml,
                error: function (xhr, status, error) {
                     $('#output').html("An AJAX error occured: " + status + "\nError: " + error);
                }
            });
        }
        function parseXml(xml) {
            $(xml).find("GeocodeResponse").each(function () {
                if ($(this).find("status").text() == "OK") {
                    parseOkXml(xml)
                }
                else {
                    $('#output').html('response code was not OK');
                }
            });
        }
        function parseOkXml(xml) {
            $(xml).find('type').each(function () { // find all "type" tag in XML
                if ($(this).text() == 'administrative_area_level_1') { // in here $(this) is our "type" tag
                    add($(this).parent().find('long_name').text());
                    //return false;
                }
				 if ($(this).text() == 'administrative_area_level_2') { // in here $(this) is our "type" tag
                    add($(this).parent().find('long_name').text());
                    //return false;
                }
				 if ($(this).text() == 'administrative_area_level_3') { // in here $(this) is our "type" tag
                    add($(this).parent().find('long_name').text());
                    //return false;
                }
            });
        }
		function add(data)
		{
                $('#location').append('');
		}
    </script>

Proxy code to load maps data from google getLocationResponse.ashx

 

<%@ WebHandler Language="C#" Class="getLocationResponse" %>
using System;
using System.Web;
using System.Net;
using System.IO;

public class getLocationResponse : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/xml";
        string latlng = context.Request.QueryString["latlng"];
        string url = "http://maps.google.com/maps/api/geocode/xml?latlng=" + latlng + "&sensor=true";
        WebRequest request = WebRequest.Create(url);
        request.Timeout = 1000;
        ;


        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        {
            using (Stream dataStream = response.GetResponseStream())
            {
                using (StreamReader reader = new StreamReader(dataStream))
                {
                    context.Response.Write(reader.ReadToEnd());
                }
            }
        }
    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}

 you now can request location info by calling find() JavaScript function from html

Tags: , , , , ,

ASP.NET | Mobile web | Useful

Building asp.net web applications with sqlite

by nolovelust 26. November 2010 13:43

If you want to build and asp.net web site/application that is interactive you mostly use SQL server as backend for your site.
But sometimes you don't need full-fledged server; you could be building a personal site or a site with low traffic. In cases where you don’t need a SQL server one of the choices is SQLite database.
I’ve build couple of sites with SQLite and quite happy with performance. Although it is not recommended to use it on high traffic sites I have not seen any problem with sites that have 50-60 users online at any given time.


To use SQLite on your site as database provider you need couple of things


• Up-to-date version of SQLite .Net from http://sqlite.phxsoftware.com/
• To create/design my databases I use SQLite Admin from http://sqliteadmin.orbmu2k.de/ but you can use Visual Studio addin of SQLite .Net too.

Once you install above files all you need to do is create an empty asp.net website/application and put System.Data.SQLite.DLL in to your Bin folder. Create a SQLite database and put it to your App_Data folder.
You can connect to it with connection string like below

          static string connString = "Data Source=" + SqliteDataBasePath + "; Journal Mode=Off; Compress=True; Version=3;";

I use below class to communicate with SQLite Databases. It is quite simple.

using System.Data;
using System.Data.SQLite;
using System.Web;

/// 
/// Summary description for DB
/// 
public class DB
{

    public static DataSet GetTables(string sql)
    {
        DataSet ds = new DataSet();

        using (SQLiteConnection conn = new SQLiteConnection(connString))
        {
            conn.Open();
            using (SQLiteCommand cmd = new SQLiteCommand(conn))
            {
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;
                using (SQLiteDataAdapter da = new SQLiteDataAdapter(cmd))
                {
                   
                    da.Fill(ds);
                    return ds;
                }
            }
        }

    }
    public static int ExecuteNonQuery(string sql)
    {
        using (SQLiteConnection conn = new SQLiteConnection(connString))
        {
            conn.Open();
            using (SQLiteCommand cmd = new SQLiteCommand(conn))
            {
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;
                int rowsUpdated = cmd.ExecuteNonQuery();
                return rowsUpdated;

            }
        }

    }
    public static string ExecuteScalar(string sql)
    {

        using (SQLiteConnection conn = new SQLiteConnection(connString))
        {
            conn.Open();

            using (SQLiteCommand cmd = new SQLiteCommand(conn))
            {
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;
                object value = cmd.ExecuteScalar();
                if (value != null)
                {
                    return value.ToString();
                }
                else
                {
                    return "";
                }
            }

        }
    }  
    
}

Tags:

ASP.NET | Useful

ASP.net Large download handler - downloader blocks subsequent requests

by nolovelust 5. October 2010 18:55

I've been having few problems with my Asp.net downloader (see http://nolovelust.com/post/C-file-downloader-AKA-ResponseBinaryWrite.aspx). Problem was that if I start to download a file Asp.net would not respond to other requests from same session. After a bit of research I've came accross http://forums.asp.net/t/1204045.aspx and http://www.guidanceshare.com/wiki/ASP.NET_2.0_Performance_Guidelines_-_Session_State

So by adding EnableSessionState="ReadOnly" to my page i was able to get Aps.net to respond subsequent requests

Tags:

ASP.NET | Useful

Simple URL Checker/Validator to check and sort active URLs in a list

by nolovelust 20. July 2010 13:06

I have couple of sites where i need to keep up to date list or large amount of web sites. It is not easy job to make sure all web sites in the list are active. I've looked around for a simple and free software to automate this job but couldn't find one that meets my needs. There are commercial solutions but I don't really like to pay for something I can write.

 

So here is a simple app called URLChecker to validate/check active URLs in a list.  It is nothing fancy but does the job.

 

 

Download URLChecker.zip (53.11 kb) Requires .Net 3.5

URLChecker-Soruce.zip (157.88 kb) C# source code for URLChecker if anyone wants to edit/change as they wish.

Tags: , , ,

ASP.NET | Open Source | Useful

Tag cloud

Month List