在服务器上上传 .aspx 文件时出错

发布于 2025-01-06 19:32:10 字数 5093 浏览 0 评论 0原文

当我在服务器上上传 .aspx 文件时,出现运行时错误。我之前上传过相同格式的文件,并且它们工作正常,因此我的服务器确实支持此服务。 此外,该应用程序在我的本地服务器上运行良好。

这是错误:
运行时错误

描述:服务器上发生应用程序错误。此应用程序的当前自定义错误设置阻止远程查看应用程序错误的详细信息(出于安全原因)。但是,它可以通过本地服务器计算机上运行的浏览器查看。

详细信息:要在远程计算机上查看此特定错误消息的详细信息,请在位于当前 Web 应用程序根目录的“web.config”配置文件中创建一个标记。该标签的“mode”属性应设置为“Off”。


这是我的代码:

<%@ 页面语言="C#" %> <%@ import Namespace="System.IO" %> <%@ import Namespace="系统" %> <%@导入

Namespace="System.Collections.Generic" %> <%@导入 命名空间=“System.Linq”%> <%@ import Namespace="System.Web" %> <%@ 导入命名空间=“System.Web.UI”%> <%@导入 命名空间=“System.Web.UI.WebControls”%>

public void Button1_Click(对象发送者,EventArgs e)
{
    //这是一个计算您的抵押贷款付款的程序

    //使用的变量 
    双p;
    双米 = 0;
    双倍率 = 0;
    整数年= 0;
    整数 ny = 0;
    布尔结果=假;

     速率 = DropDownList2.SelectedIndex; //这里我们从comboBox1中获取值并将其分配给变量“rate”


    //以下 IF 语句从单选按钮获取值并将其分配给变量“years”

    if (RadioButtonList2.SelectedIndex == 0)
    {
        年= 15;

    }
    if (RadioButtonList2.SelectedIndex == 1)
    {
        年= 30;

    }
    if (RadioButtonList2.SelectedIndex == 2 && TextBox5.Text != null)
    {
        if (int.TryParse(TextBox4.Text, out ny))
        {
            年=纽约;
        }

    }


    //一个简单的if语句来检查用户是否填写了计算所需的所有值。
    //如果任何值错误或丢失,程序会提示用户再次检查他/她的输入

    if (年份!= 0 && 比率!= 0 && double.TryParse(TextBox4.Text, out p))
    {
        m = (p * 比率 / 1200.0) / (1 - Math.Pow((1.0 + 比率 / 1200.0), -12.0 * 年));
        结果=真;


    }
    别的
    {
        TextBox6.Text = "请填写所有方框!";
    }


    //如果以上所有步骤都检查为true,则付款金额将显示在textBox3上
    如果(结果==真)
    {
        TextBox6.Text = m + "";
        StreamWriter sw = File.AppendText("d:/log_file.txt");
        sw.WriteLine(DateTime.Now + "\n金额: " + m + "");
        sw.WriteLine();
        sw.Close();
    }

}

公共无效Button2_Click(对象发送者,EventArgs e)
{
    TextBox4.Text = null;
    TextBox5.Text = null;
    TextBox6.Text = null;
    RadioButtonList2.SelectedIndex = 0;
}
公共无效Page_Load(对象发送者,EventArgs e)
{

} 

 ;

吉奥·尼古拉德斯 |每月付款

$(文档).ready(函数() { $('#page_effect').fadeIn(500); });

乔治·尼古拉德斯

IT-330

 




 ;
    
        15
        30
        其他
    
    ;

> ;
> 速率 3.0 3.5 4.0 4.5 5.0 5.5 6.0
>
>
>
> &nbsp;   
>
>
>
>

I am getting a runtime error when i upload an .aspx file on my server. I uploaded files before of the same format and they were working fine so my server does support this service.
Also, the application is working fine on my local server.

This is the error:
Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".

And this is my code:

<%@ Page Language="C#" %> <%@ import Namespace="System.IO" %> <%@ import Namespace="System" %> <%@ import

Namespace="System.Collections.Generic" %> <%@ import
Namespace="System.Linq" %> <%@ import Namespace="System.Web" %> <%@
import Namespace="System.Web.UI" %> <%@ import
Namespace="System.Web.UI.WebControls" %>

public void Button1_Click(object sender, EventArgs e)
{
    //This a program that calculates your mortgage payments

    //Variables used 
    double p;
    double m = 0;
    double rate = 0;
    int years = 0;
    int ny = 0;
    bool result = false;

     rate = DropDownList2.SelectedIndex;    //Here we get the values from the comboBox1 and assign it to the variable "rate"


    //The following IF statements get the value from the radio buttons and assign it to the variable "years"

    if (RadioButtonList2.SelectedIndex == 0)
    {
        years = 15;

    }
    if (RadioButtonList2.SelectedIndex == 1)
    {
        years = 30;

    }
    if (RadioButtonList2.SelectedIndex == 2 && TextBox5.Text != null)
    {
        if (int.TryParse(TextBox4.Text, out ny))
        {
            years = ny;
        }

    }


    //A simple if statement to check if the user filled out all values necessary for the calculation.
    //if any of the values where wrong or missing the program prompts the user to check his/her input again

    if (years != 0 && rate != 0 && double.TryParse(TextBox4.Text, out p))
    {
        m = (p * rate / 1200.0) / (1 - Math.Pow((1.0 + rate / 1200.0), -12.0 * years));
        result = true;


    }
    else
    {
        TextBox6.Text = "Please fill all boxes!";
    }


    //If all of the above steps checks true then the payment amount is displayed on textBox3
    if (result == true)
    {
        TextBox6.Text = m + "";
        StreamWriter sw = File.AppendText("d:/log_file.txt");
        sw.WriteLine(DateTime.Now + "\nAmount: " + m + "");
        sw.WriteLine();
        sw.Close();
    }

}

public void Button2_Click(object sender, EventArgs e)
{
    TextBox4.Text = null;
    TextBox5.Text = null;
    TextBox6.Text = null;
    RadioButtonList2.SelectedIndex = 0;
}
public void Page_Load(object sender, EventArgs e)
{

} </script>

  <script src="css_browser_selector.js" type="text/javascript"></script>

Geo Nicolaides | Monthly Payments

$(document).ready(function () {
$('#page_effect').fadeIn(500);
});

George Nicolaides

IT-330

<div class="footer">

  <div id="nav">

      <div class="navlist1">

          <ul> <li> <a class="navlist" href="index.html">Home</a> </li></ul>

      </div>

     <div class="navlist1">

          <ul> <li><a class="active" href="projects.html" >Projects</a></li> </ul>

      </div>



        <div class="navlist1">

          <ul> <li><a class="navlist" href="view-log.aspx" >Log Files</a></li> </ul>

      </div>          



  </div>



</div> </div>
<div class="wrapper2">            





<div class="content">

<div id="page_effect" style="display:none;"> 
    <asp:Label ID="Label6" runat="server" Text="Years of payments:" ForeColor="White"></asp:Label>
    <asp:RadioButtonList ID="RadioButtonList2" runat="server" style="margin-left:0px; color:White;">
        <asp:ListItem>15</asp:ListItem>
        <asp:ListItem>30</asp:ListItem>
        <asp:ListItem>Other</asp:ListItem>
    </asp:RadioButtonList>
    <asp:TextBox ID="TextBox5" runat="server" style="margin-left:0px" Width="47px"></asp:TextBox>
<br />
    <asp:Label ID="Label7" runat="server" Text="Interest Rate" ForeColor="White"></asp:Label>    <br />
    <asp:DropDownList ID="DropDownList2" runat="server" Height="23px" 
        style="margin-left: 0px">
        <asp:ListItem Selected="True">Rate</asp:ListItem>
        <asp:ListItem>3.0</asp:ListItem>
        <asp:ListItem>3.5</asp:ListItem>
        <asp:ListItem>4.0</asp:ListItem>
        <asp:ListItem>4.5</asp:ListItem>
        <asp:ListItem>5.0</asp:ListItem>
        <asp:ListItem>5.5</asp:ListItem>
        <asp:ListItem>6.0</asp:ListItem>
    </asp:DropDownList>
  <br /> <br />

    <asp:Button ID="Button2" runat="server" style="margin-left: 0px" 
        Text="Calculate" onclick="Button1_Click" ForeColor="Black" 
    Height="37px" Width="119px"  />

 <br /> <br />

    <asp:Label ID="Label8" runat="server" Text="Monthly Payment:" ForeColor="White"></asp:Label>
    
    <asp:TextBox ID="TextBox6" runat="server" style="margin-left: 0px" 
        AutoPostBack="True" BackColor="White" Columns="50" ReadOnly="True" 
        ViewStateMode="Enabled" Width="142px"></asp:TextBox>
<br />
  <br />
    <asp:Button ID="Button1" runat="server" style="margin-left: 0px" 
        Text="Reset" onclick="Button2_Click" ForeColor="Black" 
    Height="37px" Width="119px"  />

 <br /> <br />

    <div class="largespacebelow">


  </div>            



  </div>

  </div>

  </div>



  <div class="push2">          

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请你别敷衍 2025-01-13 19:32:10

您的第一步应该是获取“真正的”错误。如果您对服务器具有本地/GUI 访问权限,请登录并尝试浏览本地主机上的页面。

否则,您应该编辑 web.config 以将 customerrors 模式设置为关闭,以便您可以远程查看详细的错误报告。注意:如果您担心安全问题,请不要这样做,但我假设这不是任何类型的实时高流量公共网站。

这里是关于customerrors web.config元素的页面,但基本上你只需将“模式”位翻转为“关闭”即可。这将为您提供更多可供使用的信息。

在浏览完您的代码后我注意到一件事(这可能只是因为格式完全搞砸了),但我之前没有看到开放的

Your first step should be to get the 'real' error. If you have local/GUI access to the server, log in and try to browse to the page at localhost.

Otherwise, you should edit your web.config to set the customerrors mode to off so you can see the detailed error report remotely. Note: Do not do this if you are worried about security implications, but I'm assuming this isn't any sort of live high-traffic public website.

Here is the page about the customerrors web.config element, but basically you just flip the "mode" bit to "off". That should give you a lot more information to work with.

One thing I notice after a once-over of your code (and this may just be because the formatting is all kinds of screwed up), but I don't see an opening <script> tag before your button1_click method. You should also consider moving all of the C# to a code-behind file to separate the logic and design and make everything easier to read and maintain.

月寒剑心 2025-01-13 19:32:10

我的网站顶部有一个错误的命名空间。

I had a wrong Namespace on the top of my site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文