小编Fun*_*rit的帖子

响应在 asax 文件中的此上下文中不可用

我有一个仅适用于 Firefox 的登录页面。它不适用于任何其他浏览器。

当我检查事件日志时,我看到“响应在当前上下文中不可用”。它告诉我错误在 global.asax 文件中的 response.redirect 行:

void Session_End(object sender, EventArgs e) 
{
     Response.Redirect("~/Login.aspx?li=1");
    // Code that runs when a session ends. 
    // Note: The Session_End event is raised only when the sessionstate mode
    // is set to InProc in the Web.config file. If session mode is set to StateServer 
    // or SQLServer, the event is not raised.

}
Run Code Online (Sandbox Code Playgroud)

可能是什么问题呢?

我已经按照建议尝试了 httpcontext.Current 但后来我得到了一个空引用异常,对象引用未设置为对象的实例

谢谢你。

c#

5
推荐指数
1
解决办法
1万
查看次数

使用SSL连接发送CDO电子邮件

我有一个asp页面,通过电子邮件使用CDO发送表单的详细信息.到目前为止,我已经通过与hmail服务器的明确连接使用smtp端口25完成了此操作.

我现在需要使用SSL连接.我创建了一个安全证书并设置了hmail服务器以使用端口465和ssl.

但是,出于某种原因,当我尝试发送表单时,我收到错误500并且未发送电子邮件.

我也试过端口587,但它也不起作用.

我使用的CDO代码如下:

If request.Form("submit") <> "" then

Set myMail=CreateObject("CDO.Message")
myMail.Subject="xxxxxxx"
myMail.From=Request.Form("email")
myMail.To= "xxxxxxxxxxx"

myMail.TextBody = "Name:"& Request.Form("name")& vbcrlf & vbcrlf & _

"Email:" & Request.Form("email") & vbcrlf & vbcrlf &  _

"Telephone:" & Request.Form("telephone") & vbcrlf & vbcrlf & _

"Location:" & Request.Form("location") & vbcrlf & vbcrlf & _

"Other location:" & Request.Form("other_location") & vbcrlf & vbcrlf & _

"Comments:" & Request.Form("comments")

myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
="127.0.0.1" …
Run Code Online (Sandbox Code Playgroud)

ssl cdo.message hmail-server

2
推荐指数
2
解决办法
2万
查看次数

标签 统计

c# ×1

cdo.message ×1

hmail-server ×1

ssl ×1