Click here to Skip to main content
15,892,199 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionError Pin
Flavia A22-Jun-09 23:36
Flavia A22-Jun-09 23:36 
AnswerRe: Error Pin
Christian Graus22-Jun-09 23:58
protectorChristian Graus22-Jun-09 23:58 
AnswerRe: Error Pin
Abhijit Jana23-Jun-09 0:23
professionalAbhijit Jana23-Jun-09 0:23 
GeneralRe: Error Pin
Flavia A23-Jun-09 0:45
Flavia A23-Jun-09 0:45 
GeneralRe: Error Pin
himanshu256123-Jun-09 0:47
himanshu256123-Jun-09 0:47 
GeneralRe: Error Pin
Abhijit Jana23-Jun-09 0:49
professionalAbhijit Jana23-Jun-09 0:49 
QuestionRegarding Asp >net with Hibernate:web.Cofing error Pin
RAKESH gaur mkcl22-Jun-09 21:49
RAKESH gaur mkcl22-Jun-09 21:49 
QuestionSystem.Drawing.Image " Security Error" Pin
Robymon22-Jun-09 20:56
Robymon22-Jun-09 20:56 
Some security error showing when i am trying to upload the image. it is working fine in the source code(Localy), but after uploading the page and trying getting the following error. Error is showing in the System.Drawing.Image Part.

Error Details as follows

Server Error in '/' Application.
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

Line 68: int thumbWidth = 0;
Line 69:
Line 70: System.Drawing.Image image = System.Drawing.Image.FromFile(cmdUpload.PostedFile.FileName);
Line 71: if (image.Width > 500)
Line 72: {


Source Code as follows

int thumbWidth = 0;

System.Drawing.Image image = System.Drawing.Image.FromFile(cmdUpload.PostedFile.FileName);
if (image.Width > 500)
{
thumbWidth = 500;
}
else
{
thumbWidth = image.Width;
}
int srcWidth = image.Width;
int srcHeight = image.Height;
Decimal sizeRatio = ((Decimal)srcHeight / srcWidth);
int thumbHeight = Decimal.ToInt32(sizeRatio * thumbWidth);
Bitmap bmp = new Bitmap(thumbWidth, thumbHeight);
System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bmp);
gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
System.Drawing.Rectangle rectDestination = new System.Drawing.Rectangle(0, 0, thumbWidth, thumbHeight);
gr.DrawImage(image, rectDestination, 0, 0, srcWidth, srcHeight, GraphicsUnit.Pixel);
Font font = new Font("Verdana", 14, FontStyle.Bold, GraphicsUnit.Pixel);
Color color = Color.FromArgb(100, 0, 0, 0);
Point pt = new Point(2, 3);
SolidBrush sbrush = new SolidBrush(color);
gr.DrawString("www.Test.com", font, sbrush, pt);
System.IO.MemoryStream stream = new System.IO.MemoryStream();
bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
stream.Position = 0;
byte[] picture = new byte[stream.Length];
stream.Read(picture, 0, (int)stream.Length); // < - - Saving to SQL Server - - >
string result = string.Empty;
result = DatabaseLayer.Wishes.InsertWishes(category, Convert.ToInt32(ddNumber.SelectedValue), ddCh.SelectedIndex, txtDate.Text, picture, txtName.Text, txtHouseName.Text, txtEmail.Text, txtComment.Text);
ddNumber.SelectedIndex = 0;
ddCh.SelectedIndex = 0;
txtDate.Text = "";
txtName.Text = "";
txtHouseName.Text = "";
txtEmail.Text = "";
txtComment.Text = "";
Label1.Text = "";
bmp.Dispose();
image.Dispose();
Page page = HttpContext.Current.Handler as Page;

if (page != null)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "msgbox", "alert('" + result + "');", true);
}
AnswerRe: System.Drawing.Image " Security Error" Pin
Christian Graus22-Jun-09 23:59
protectorChristian Graus22-Jun-09 23:59 
GeneralRe: System.Drawing.Image " Security Error" Pin
Robymon23-Jun-09 0:12
Robymon23-Jun-09 0:12 
GeneralRe: System.Drawing.Image " Security Error" Pin
Christian Graus23-Jun-09 0:55
protectorChristian Graus23-Jun-09 0:55 
Question[Message Deleted] Pin
KhandelwalA22-Jun-09 20:46
KhandelwalA22-Jun-09 20:46 
AnswerRe: error: The server tag is not well formed Pin
himanshu256122-Jun-09 20:59
himanshu256122-Jun-09 20:59 
GeneralRe: error: The server tag is not well formed Pin
KhandelwalA22-Jun-09 21:04
KhandelwalA22-Jun-09 21:04 
GeneralRe: error: The server tag is not well formed Pin
himanshu256122-Jun-09 21:11
himanshu256122-Jun-09 21:11 
GeneralRe: error: The server tag is not well formed Pin
J4amieC22-Jun-09 23:08
J4amieC22-Jun-09 23:08 
GeneralRe: error: The server tag is not well formed Pin
KhandelwalA22-Jun-09 23:13
KhandelwalA22-Jun-09 23:13 
GeneralRe: error: The server tag is not well formed Pin
Christian Graus23-Jun-09 0:00
protectorChristian Graus23-Jun-09 0:00 
GeneralRe: error: The server tag is not well formed Pin
KhandelwalA23-Jun-09 0:06
KhandelwalA23-Jun-09 0:06 
AnswerRe: error: The server tag is not well formed Pin
himanshu256122-Jun-09 21:08
himanshu256122-Jun-09 21:08 
GeneralRe: error: The server tag is not well formed Pin
KhandelwalA22-Jun-09 21:17
KhandelwalA22-Jun-09 21:17 
GeneralRe: error: The server tag is not well formed Pin
K030622-Jun-09 21:35
K030622-Jun-09 21:35 
AnswerRe: error: The server tag is not well formed Pin
padmanabhan N22-Jun-09 21:22
padmanabhan N22-Jun-09 21:22 
Questionproblem in sending mail using gmail account Pin
prateekfgiet22-Jun-09 20:27
prateekfgiet22-Jun-09 20:27 
AnswerRe: problem in sending mail using gmail account Pin
Abhishek Sur22-Jun-09 22:13
professionalAbhishek Sur22-Jun-09 22:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.