My website is using asp.net with c#. Recently i am adding a new function by adding a flash webcam photo capture. In local it can function well, it can capture photo, save into database, and display the photo. However, after deploy it cannot funtion well on my server. The webcam still can function. But it cannot convert and save that photo into database. I suspect the actionscript cannot fire... Do i need to install any flash player into my server? Anybody can help me? Pls help... Urgent. TQ

Dani AI

Generated

A concise troubleshooting summary and checklist based on the thread (Firebug shows HTTP 500; ImageConversions.aspx handles the POST on Page_Load; already suggested folder/limits checks).

Likely causes (in order of probability): the Flash POST reaches the site but server-side code raises an exception before logging (common culprits are null Session values when the request lacks cookies, a missing physical path or insufficient write rights, or the POST body not being where the code expects). Other frequent causes are request-size limits and Flash sending a raw body or a data-URI prefix instead of a form field.

Quick diagnostic checklist

  • Capture the full request/response with Fiddler (URL, Content-Type, POST body, cookies) and note the IIS substatus (500.x) in the IIS logs.
  • Verify whether the POST actually contains an imageData key. If not present, inspect Request.InputStream / raw body; Flash sometimes posts raw data or includes a "data:image/..." prefix that must be stripped before base64-decoding.
  • Confirm Session usage: the page reads Session items on Page_Load. A POST without the browser session cookie causes null Session values and a NullReferenceException. Either pass account/member IDs in the POST from Flash or use a dedicated upload endpoint that does not depend on Session.
  • Use Server.MapPath to resolve the physical file path and ensure the MemberPicture folder exists. Grant the application pool identity Modify rights on that folder.
  • Raise allowed upload sizes (httpRuntime maxRequestLength in KB and IIS requestFiltering maxAllowedContentLength in bytes) to accommodate base64 expansion.
  • Enable detailed errors temporarily (customErrors off / debug) and check Windows Event Viewer and IIS logs if the app’s log file remains empty.
  • Add a tiny test endpoint (handler or simple aspx) that logs Request.Form keys, Content-Type and Session state at the very start of the request to prove where failure occurs.

Notes tied to thread: 's folder/limit advice is correct. Given 's Firebug 500 result and the Page_Load Session reads, missing session or a path/permission problem is the most likely root cause. If the raw request capture and IIS 500.x substatus are provided, the debugging steps narrow quickly.

Recommended Answers

All 13 Replies

You'll need to provide relevant code / error messages.

//This is my code.... Pls help... TQ

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Data.SqlClient;
using Pic.User;
using Pic.Action;
using Pic.Common;

namespace Pic
{
public partial class ImageConversions : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
clsAction action = new clsAction();

DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");
string imgMember = time + ".jpg";
string imgPath = "MemberPicture/" + imgMember;


txtAcc.Text = Session["Cust"].ToString();
lblGeoID.Text = Session["geoID"].ToString();
//lblMNo.Text = Session["memberNo"].ToString();
//lblMName.Text = Session["memberName"].ToString();
lblMember.Text = Session["Member"].ToString();
//string memberID = Convert.ToInt32(txtAcc.Text);
int memberGeoID = Convert.ToInt32(lblGeoID.Text);

CreatePhoto();

action.ExecuteInsert(imgMember, imgPath, txtAcc.Text, memberGeoID,lblMember.Text);


}

void CreatePhoto()
{
try
{
string strPhoto = Request.Form["imageData"]; //Get the image from flash file
byte[] photo = Convert.FromBase64String(strPhoto);

DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");

//get the file name of the posted image
string imgMember = time + ".jpg";

//sets the image path
string imgPath = "MemberPicture/" + imgMember;

//then save it to the Folder
FileStream fs = new FileStream(imgPath, FileMode.OpenOrCreate, FileAccess.Write);

BinaryWriter br = new BinaryWriter(fs);
br.Write(photo);
br.Flush();
br.Close();
fs.Close();

}
catch (Exception Ex)
{
throw;
}
}
}
}
//=======================================================================================================
public void ExecuteInsert(string member, string path, string acNo, int memberGeoID, string memberNo)
{
try
{
clsDB db = new clsDB();

clsUser user = new clsUser();


SqlParameter[] sqlParams = {
new SqlParameter("@ImageMember", member),
new SqlParameter("@ImgPath", path),
new SqlParameter("@MID", acNo),
new SqlParameter("@M_GeoID", memberGeoID),
//new SqlParameter("@MNo", MNo),
//new SqlParameter("@MName", MName),
new SqlParameter("@memberNo", memberNo)
};

db.ExecuteStoredProcedure("spAddMemberPic", sqlParams);

}
catch (Exception)
{
throw;
}
}

You shouldn't declare the imgMember and imgPath twice(once in each function) this can lead to the image being saved with one name to the disk and in the DB with another.
Create the name only in the page load and pass it as a paramater to the CreatePhoto method.

Did you check if the image is being saved to disk but not on the DB or the vice-versa?

Another thing, you're not handling any exceptions. I'd suggest you log them to a .txt file so you can verify exatcly what's going on.

You could also use a network watcher, like FireBug or Developer's Tools to verify if the imageData parameter is being sent or not.

Another thing that may be the problem is the size of the image. Verify the request limit and request timeout on your webconfig.

I used firebug. It shows "500 Internal Server Error".

I have added a Log.txt file. My Log.txt file is worked. I have try to input other error. Log.txt has an error message. But now is no error shown. I think it never go to this page. This page is fire from the button "Capture" in flash. I suspect the action script in flash do not fire.

Wich URL gives HTTP error 500?

This page that i haved pasted above. ImageConversions.aspx

Were you able to log the exceptions?

A question, the user running the application on the server has permission to write files to the disk? If it doesn't, it would cause the error.

I have opened the file access .... still cannot....

**Were you able to log the exceptions? **
When the catch() occurs save the message details into a txt file and post it back here.

//I have modified my code to become like this. 
//Logfile does not show any error message.
//Still cannot function well in server but can function well in local only.

namespace Pic
{
public partial class ImageConversions : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
clsAction action = new clsAction();

DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");
string imgMember = time + ".jpg";
string fName="MemberPicture/";
string imgPath = Path.Combine(fName,imgMember);

try
{
txtAcc.Text = Session["Cust"].ToString();
lblGeoID.Text = Session["geoID"].ToString();
lblMember.Text = Session["Member"].ToString();
int memberGeoID = Convert.ToInt32(lblGeoID.Text);

CreatePhoto();

action.ExecuteInsert(imgMember, imgPath, txtAcc.Text, memberGeoID, lblMember.Text);
lblMsg.Text = "Success";
}
catch (Exception ex)
{
FileInfo txt = new FileInfo("Log.txt");
StreamWriter sw = txt.AppendText();
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + "Line No:" + ex.Source + " Message " + ex.Message);
sw.WriteLine(" ");
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + ex.StackTrace);
sw.WriteLine(" ");
sw.WriteLine(" ");
sw.Close();
}


}

void CreatePhoto()
{
try
{
string strPhoto = Request.Form["imageData"]; //Get the image from flash file
byte[] photo = Convert.FromBase64String(strPhoto);

DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");

//get the file name of the posted image
string imgMember = time + ".jpg";
string fName = "MemberPicture/";
string imgPath = Path.Combine(fName, imgMember);

string fileName = Path.Combine(fName,imgPath);
using (var fs = new FileStream(imgPath, FileMode.OpenOrCreate, FileAccess.Write))
{
// read the file
BinaryWriter br = new BinaryWriter(fs);
br.Write(photo);
br.Flush();
br.Close();
fs.Close();
}
}
catch (Exception ex)
{
FileInfo txt = new FileInfo("Log.txt");
StreamWriter sw = txt.AppendText();
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + "Line No:" + ex.Source + " Message " + ex.Message);
sw.WriteLine(" ");
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + ex.StackTrace);
sw.WriteLine(" ");
sw.WriteLine(" ");
sw.Close();
}
}
}
}

Try like this and see if it works or if it writes the exception on Log.txt.
Also, make sure that the folder MemberPicture exists on the server.

namespace Pic
{

    public partial class ImageConversions : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            clsAction action = new clsAction();

            DateTime thisDay = DateTime.Now;
            string time = thisDay.ToString("yyyyMMMd HHmmss");
            string imgMember = time + ".jpg";
            string fName="MemberPicture/";
            string imgPath = Path.Combine(fName,imgMember);

            try
            {
                txtAcc.Text = Session["Cust"].ToString();
                lblGeoID.Text = Session["geoID"].ToString();
                lblMember.Text = Session["Member"].ToString();
                int memberGeoID = Convert.ToInt32(lblGeoID.Text);

                CreatePhoto(imgPath);

                action.ExecuteInsert(imgMember, imgPath, txtAcc.Text, memberGeoID, lblMember.Text);
                lblMsg.Text = "Success";
            }
            catch (Exception ex)
            {
                LogException(ex);
            }


        }

        protected void CreatePhoto(string imgPath)
        {
            try
            {
                string strPhoto = Request.Form["imageData"]; //Get the image from flash file
                byte[] photo = Convert.FromBase64String(strPhoto);

                string fileName = Path.Combine(fName,imgPath);
                using (var fs = new FileStream(imgPath, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    // read the file
                    BinaryWriter br = new BinaryWriter(fs);
                    br.Write(photo);
                    br.Flush();
                    br.Close();
                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }

        protected void LogException(Exception ex)
        {
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(Server.MapPath("~/Log.txt"), true))
            {
                file.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + "Line No:" + ex.Source + " Message " + ex.Message);
                file.WriteLine(" ");
                file.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + ex.StackTrace);
                file.WriteLine(" ");
                file.WriteLine(" ");
            }
        }
    }

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.