62,243
社区成员




<script language="c#" runat="server">
void loglog(object sender, EventArgs e)
{
string Path = @"D:\log\log.txt";
if (!System.IO.File.Exists(Path))
{
System.IO.FileStream f = System.IO.File.Create(Path);
f.Close();
f.Dispose();
}
System.IO.StreamWriter f2 = new System.IO.StreamWriter(Path, true,
System.Text.Encoding.GetEncoding("gb2312"));
f2.WriteLine(Request["st"].ToString());
f2.Close();
f2.Dispose();
}
</script>
<%
string Path = @"D:\log\log.txt";
if (!System.IO.File.Exists(Path))
{
System.IO.FileStream f = System.IO.File.Create(Path);
f.Close();
f.Dispose();
}
System.IO.StreamWriter f2 = new System.IO.StreamWriter(Path, true,
System.Text.Encoding.GetEncoding("gb2312"));
f2.WriteLine(Request["st"].ToString());
f2.Close();
f2.Dispose();
response.write("True")
%>
然后浏览器地址栏直接输入:http://…………/log.aspx?st=logtest就可以把logtest写入D:\log\log.txt文件(当然前提是你这段代码没问题而且有权限),或者
<form name='form1' method="post" action="log.aspx">
<input name="st" type="text" value="logtest" />
<input name="button" type="button" value="提交" />
</form>
这种表单提交的方式,或者ajax之类的,jquery不会的话也可以直接原生javascript实现,当然前面的log.aspx也可以用.ashx、.asmx之类的替代,方法多了去了[/quote]懂了,谢谢,去试试
<%
string Path = @"D:\log\log.txt";
if (!System.IO.File.Exists(Path))
{
System.IO.FileStream f = System.IO.File.Create(Path);
f.Close();
f.Dispose();
}
System.IO.StreamWriter f2 = new System.IO.StreamWriter(Path, true,
System.Text.Encoding.GetEncoding("gb2312"));
f2.WriteLine(Request["st"].ToString());
f2.Close();
f2.Dispose();
response.write("True")
%>
然后浏览器地址栏直接输入:http://…………/log.aspx?st=logtest就可以把logtest写入D:\log\log.txt文件(当然前提是你这段代码没问题而且有权限),或者
<form name='form1' method="post" action="log.aspx">
<input name="st" type="text" value="logtest" />
<input name="button" type="button" value="提交" />
</form>
这种表单提交的方式,或者ajax之类的,jquery不会的话也可以直接原生javascript实现,当然前面的log.aspx也可以用.ashx、.asmx之类的替代,方法多了去了
$('#dom元素id').click(()=>{
$.get('你的请求地址',(result)=>{
alert(result)
})
})
任意action(){
string Path = @"D:\log\log.txt";
if (!System.IO.File.Exists(Path))
{
System.IO.FileStream f = System.IO.File.Create(Path);
f.Close();
f.Dispose();
}
System.IO.StreamWriter f2 = new System.IO.StreamWriter(Path, true,
System.Text.Encoding.GetEncoding("gb2312"));
f2.WriteLine(Request["st"].ToString());
f2.Close();
f2.Dispose();
}