Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,030

HOME > .NET Framework > Forum > เกี่ยวกับasp.net รู้สึกdebugแปลกช่วยดูหน่อยครับ เขียนโค๊ตเกี่ยวกับevent-driven



 

เกี่ยวกับasp.net รู้สึกdebugแปลกช่วยดูหน่อยครับ เขียนโค๊ตเกี่ยวกับevent-driven

 



Topic : 013062

Guest




code ที่เขียนครับ
<%@Import Namespace= "System.IO" %>
ข้อความที่1
<script language="VB" runat="server">
Dim A As Integer
Sub Page_Init(Sender As Object,E As EventArgs)
A= 10
Response.Write(A)
label1.Text = A
End Sub
Sub Page_Load(Sender As Object,E As EventArgs)
A=A+1
Response.Write(A)
label1.Text = A
End Sub
Sub button1_Click(Sender As Object,E As EventArgs)
A=A+2
Response.Write(A)
label1.Text = A
End Sub
Sub Page_Unload(Sender As Object,E As EventArgs)
Dim ObjStreamWriter As StreamWriter = File.CreateText("C:\a.txt")
ObjStreamWriter.WriteLine("Hello World")
ObjStreamWriter.Close
End Sub
</script>
<form runat="server">
<asp:Button id="button1" Text="Submit" OnClick="button1_Click" runat="server" />
<asp:Label id="label1" runat="server" />
</form>
ข้อความที่2

ส่วนตอนที่มันรันเป็นแบบนี้ครับ

Server Error in '/' Application.
--------------------------------------------------------------------------------

Access to the path "c:\a.txt" is denied.
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.UnauthorizedAccessException: Access to the path "c:\a.txt" is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

<%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your application:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

Stack Trace:


[UnauthorizedAccessException: Access to the path "c:\a.txt" is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) +44
System.IO.StreamWriter.CreateFile(String path, Boolean append) +55
System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize) +49
System.IO.StreamWriter..ctor(String path, Boolean append) +66
System.IO.File.CreateText(String path) +32
ASP.Event_Driven_Page_aspx.Page_Unload(Object Sender, EventArgs E) +11
System.Web.UI.Control.OnUnload(EventArgs e) +67
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +121
System.Web.UI.Page.ProcessRequestCleanup() +24
System.Web.UI.Page.ProcessRequest() +218
System.Web.UI.Page.ProcessRequest(HttpContext context) +18
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +179
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573


Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 3 เม.ย. 2550 17:31:29 By : ปอม View : 3961 Reply : 4
 

 

No. 1

Guest


ใช่ค่ะเป็นเหมือนกันกะเรา เลย ใครรู้ ช่วยด้วยค่ะ มือใหม่ไม่คราบจริง ๆ ขอบคุณค่ะ






Date : 15 พ.ค. 2550 10:01:07 By : savewater
 


 

No. 2

Guest


ผมก็เจอครับช่วยด้วยหาวิธีแด้ไม่ได้เลยเห็นเขาบอกว่าแก้ตรง Permission ผมไม่รู้ว่ามันอยู่ตรงไหน
Date : 1 ม.ค. 2551 13:53:31 By : เต๋า
 

 

No. 3



โพสกระทู้ ( 11 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ลองไปที่ adminstrative tool-->local user and Groups-->เลือก asp.net แล้ว add สิทธิ์ตรง member of ให้เป็น administrator ดูครับ ไม่ทราบได้กันยัง ลองดูครับ
Date : 2010-07-01 20:35:50 By : Boonsong
 


 

No. 4



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


เป็นเรื่อง permission นั่นแหละครับ

ถ้าไม่ serious เรื่อง security ก็คลิกขวาที่ folder แล้ว share full เลยครับ

ส่วนถ้าอยากให้ advance มากกว่านี้ก็กำหนด permission ให้ user ชื่อ asp.net

สามารถเขียนข้อมูลใน folder ได้ก็ได้

ปล. เพิ่งเห็นวันที่ กระทู้ตั้งแต่เกือบ 3 ปีที่แล้วยังขยันขุดขั้นมาอีก
Date : 2010-07-01 22:13:32 By : tungman
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : เกี่ยวกับasp.net รู้สึกdebugแปลกช่วยดูหน่อยครับ เขียนโค๊ตเกี่ยวกับevent-driven
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่