为什么错误后显示ASP.NET代码文件? [英] Why ASP.NET Code File Shown after Error?

查看:50
本文介绍了为什么错误后显示ASP.NET代码文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这次我再次使用ASP.Net Query,;)

我的服务器正在更新时,我有以下代码与我们联系,如果有人填写该表,则显示错误消息,如"由于目标计算机拒绝...(IP地址:端口)而无法建立连接 b>"

然后我的原始问题从这里开始. . . .

(1)我不想显示的后端代码显示(用contact.aspx.vb编写),该怎么办?

(2)我的电子邮件ID和密码在这种类型的错误期间显示,如何将所有错误放入404(如错误页面),因此,如果服务器上发生任何错误或进程正在更新,则客户会看到错误页面而不是后端代码. /b>
欢迎您提供答案,教程或分步指南.

谢谢,

我的代码:

Hi,

I am Back again with ASP.Net Query this time, ;)

I have Contact us Form with Below Code, When My Server Take Updation , If any one Fill up form its shows error like "No connection could be made because the target machine refuse . . . ( IP address : Port )"

Then My Orignal Problem Starts Here. . . .

(1) My Back End Code Shows (Which written in contact.aspx.vb) which I dont want to SHow,How Can I do this?

(2) My EMail ID and Password shows during this type of errors, How to Put all error in 404 like error Page, so if anything goes wrong on server or updation on process, customers see the error page not the back end code.

Discribed answer , Tutorial or Step-by-Step Guides are most welcome.

Thanks,

My Code :

Imports System.Web.Mail
Imports System.Text

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
        Dim Body As String = "From:" + fullname.Text + Environment.NewLine + "Mobile:" + mbltxt.Text + Environment.NewLine + "EMail:" + emailtxt.Text + Environment.NewLine + Environment.NewLine + "Message:" + Environment.NewLine + bodytxt.Text
        Dim MM As New System.Net.Mail.SmtpClient
        MM.EnableSsl = False
        MM.Host = "mail.mydomainname.co.in"

        Dim cred As New System.Net.NetworkCredential("help@mydomainname.co.in", "mypassword")
        MM.Credentials = cred
        MM.Send(emailtxt.Text, "help@mydomainname.co.in", subtxt.Text, Body)
        clrfld()
        ''MsgBox("Thank You !" + Environment.NewLine + "Your Message has been Sent.", MsgBoxStyle.Information, "EMail Sent")
      Catch ex As Exception         
                ''MsgBox("Thank You !" + Environment.NewLine + "Your Message has been Sent.", MsgBoxStyle.Information, "EMail Sent")
     End Try
     End Sub
    Sub clrfld()
        fullname.Text = ""
        mbltxt.Text = ""
        emailtxt.Text = ""
        subtxt.Text = ""
        bodytxt.Text = ""
    End Sub
End Class

推荐答案

第二个问题.您可以通过将特定错误与特定错误页面相关联来进一步使用自定义错误处理. customErrors部分可以包含将特定错误与错误页面相关联的错误元素.
For your second problem. you can use custom error handling a step further by associating specific errors with specific error pages. The customErrors section can contain error elements that associate particular errors with error pages.
<configuration>
   <system.web>
     <customErrors mode="RemoteOnly" defaultRedirect="apperror.aspx"/>
     <error statusCode="404" redirect="404.aspx" />
  </configuration>


这篇关于为什么错误后显示ASP.NET代码文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆