Click here to Skip to main content
15,887,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i do have very strange problem in which when my application try to upload files (images) then values conflicting between different session like when some one upload photo then it shows photo of others ? it would like inform you all that my site have huge traffic for perticular time span ?

Is there any max. session length which can be set at IIS level ?

Please help me out ? this is very serious problem ?
Posted
Updated 22-Jan-15 20:03pm
v2
Comments
Kornfeld Eliyahu Peter 23-Jan-15 2:03am    
IIS does not 'mix' sessions - it would be useless if do so...
So probably the problem is around your code - please show us the relevant part so we could examine it...
(OT - starting your question with URGENT is a sure way to invite people to smash you down...It may be urgent for you, but we are volunteered here to answer questions and our time is our! You have to learn to manage your time!)
Gaurav Gupta A Tech Guy 23-Jan-15 2:16am    
below is the code..

i call it with a javascript funtion for google like upload u=in which it start uploading just after file selection using fileuploader.js file..



public string UploadSign(HttpPostedFileBase uploadFile, Int64 candid)
{
//List<circularfilemodel> myfile = new List<circularfilemodel>();
Int64 candidateid = 0;
string examType = "", status = "", challanNo = "";

try
{
candidateid = Convert.ToInt64(Session["CandidateID"]);
examType = Convert.ToString(Session["ExamType"]);
}
catch (Exception ex)
{

}

//string challanNo = "0";
bool isContup = false;

challanNo = candidateid.ToString() + "_" + examType;
isContup = true;

if (Request.ContentLength > 0 && isContup == true && candidateid >= 1 && candidateid == candid)
{
//CircularFileModel f1 = new CircularFileModel();

DateTime tm = DateTime.Now;
//string filename = Request.QueryString[0];
string filename = Request.QueryString["qqfile"];
string dirPath = AppDomain.CurrentDomain.BaseDirectory;
string fileURl = "./Content/writereaddata/Annual2015/";
string fileURl2 = "Content/writereaddata/Annual2015/";
if (Directory.Exists(dirPath + fileURl) == false)
{
Directory.CreateDirectory(dirPath + fileURl);
}
string cirfileName = challanNo.ToString() + "_Sign";
//string cirextn = Path.GetExtension(filename);
string cirextn = "jpg";

try
{
String fn = Path.GetFileNameWithoutExtension(filename);
String ext = Path.GetExtension(filename);
char[] SpecialChars = "!@#$%^&*()+=~`\\|/?><,\"".ToCharArray();
int indexOf = fn.IndexOfAny(SpecialChars);
String fileName1 = fn;
int count = fileName1.Split('.').Length - 1;
if (count > 1)
{
//return "Double extension not allowed in ";
return "{success:false, imsg:\"Double extension are not allowed in File-Name, please rename and try again.\"}";
}
if (indexOf != -1)
{
//return "Special character not allowed in ";
return "{success:false, imsg:\"Special character are not allowed in File-Name, please rename and try again.\"}";
}

string mimetype = Request.ContentType;
if (mimetype == "image/jpeg" || mimetype == "image/jpg" || mimetype == "image/pjpeg"
|| mimetype == "application/jpg" || mimetype == "application/x-jpg" || mimetype == "image/pipeg" || mimetype == "image/vnd.swiftview-jpeg"
|| mimetype == "image/x-xbitmap" || mimetype == "application/octet-stream")
{
if ((ext.ToLower() == ".jpg") || (ext.ToLower() == ".jpeg"))
{
fn = "";

string fFullName = filename;
int len = fFullName.Length;
string ext1 = Path.GetExtension(fFullName);
string str = fFullName.Substring(fFullName.LastIndexOf("\\") + 1);
len = str.Length;
string fileN = str.Substring(0, len - ext1.Length);

Regex FilenameRegex = null;
FilenameRegex = new Regex("(.*?)\\.(jpeg|jpg|JPEG|JPG)$", RegexOptions.IgnoreCase);
int index = fileN.IndexOf(".");
Gaurav Gupta A Tech Guy 23-Jan-15 2:19am    
//if ((firstLine.IndexOf("JFIF") > -1) || (firstLine.IndexOf("Exif") > -1))
//{
if (Request.ContentLength <= 300 * 1024)
{
//if (System.IO.File.Exists(dirPath + fileURl + cirfileName + "." + cirextn))
//{
// System.IO.File.Delete(dirPath + fileURl + cirfileName + "." + cirextn);
//}

//uploadedfile.SaveAs(context.Server.MapPath(dirPath + "/" + fileSave));

//byte[] sr = context.Request.BinaryRead(context.Request.ContentLength);

fs.Seek(0, SeekOrigin.Begin);

Stream inputStream = Request.InputStream;

if (System.IO.File.Exists(dirPath + fileURl + cirfileName + "." + cirextn))
{
System.IO.File.Delete(dirPath + fileURl + cirfileName + "." + cirextn);
}

FileStream fs1 = System.IO.File.Create(dirPath + fileURl + cirfileName + "." + cirextn);

Request.InputStream.CopyTo(fs1);

//stu_imageMBA = new Byte[Request.ContentLength];
//fs.Read(stu_imageMBA, 0, stu_imageMBA.Length);

//fs1.Write(stu_imageMBA, 0, stu_imageMBA.Length);
fs1.Close();

//Bitmap bt = new Bitmap(inputStream);
//bt.Save(context.Server.MapPath(dirPath + "/" + fileSave), ImageFormat.Jpeg);

//context.Session["Cat"] = true;
//return "{success:true, name:\"" + FileName + "\", path:\"" + Filepath + "\"}";
Session["IsSignFound"] = "1";
return "{success:true, imsg:\"Selected file is uploaded.\", name:\"" + filename + "\", path:\"" + fileURl2.Substring(1, fileURl2.Length - 1) + cirfileName + "." + cirextn + "\", spath:\"" + fileURl2 + cirfileName + "." + cirextn + "\", filetype:\"" + Request.ContentType + "\"}";
}
else
{
//return "Image size can not exceed " + size.ToString() + "kb in ";
return "{success:false, imsg:\"Image size can not exceed 100 kb in Signature file.\"}";
}
}
}
else
{
//return "Please upload .jpg or .jpeg file in ";
return "{success:false, imsg:\"Please upload .jpg or .jpeg file in Signature.\"}";
}
}
else
{
//return "Please upload .jpg or .jpeg file in ";
return "{success:false, imsg:\"Please upload .jpg or .jpeg file in Signature.\"}";
}


//f1.CircularURL = fileURl + fileName + extn;
//f1.CircularFileName = fileName;
//f1.CircularContentType = uploadFile.ContentType;

//myfile.Add(f1);
}
catch (Exception ex)
{
return "{success:false, imsg:\"Selected file is not uploaded. Please try again.\"}";
}
}


return "{success:false, imsg:\"Selected file is not uploaded. Please try again.\"}";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900