简体   繁体   English

执行当前 Web 请求期间发生未处理的异常。 ASP.NET

[英]An unhandled exception occurred during the execution of the current web request. ASP.NET

I just ran my program and I got this error message我刚刚运行了我的程序,但收到了此错误消息

An unhandled exception occurred during the execution of the current web request.执行当前 Web 请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code.请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

with stack trace带堆栈跟踪

[NullReferenceException: Object reference not set to an instance of an object.]
   OverseasCreditCard.Default.Page_Load(Object sender, EventArgs e) +667
   System.Web.UI.Control.LoadRecursive() +70
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3177

I am using ASP.NET C#, does anyone know what happened?我正在使用 ASP.NET C#,有人知道发生了什么吗?

Incomplete information: we need to know which line is throwing the NullReferenceException in order to tell precisely where the problem lies.不完整的信息:我们需要知道哪一行抛出NullReferenceException才能准确判断问题出在哪里。

Obviously, you are using an uninitialized variable (ie, a variable that has been declared but not initialized) and try to access one of its non-static method/property/whatever.显然,您正在使用未初始化的变量(即,已声明但未初始化的变量)并尝试访问其非静态方法/属性/任何内容之一。

Solution : - Find the line that is throwing the exception from the exception details - In this line, check that every variable you are using has been correctly initialized (ie, it is not null)解决方案: - 从异常详细信息中找到引发异常的行 - 在这一行中,检查您使用的每个变量是否都已正确初始化(即,它不为空)

Good luck.祝你好运。

I had the same problem and found out that I had forgotten to include the script in the file which I want to include in the live site.我遇到了同样的问题,发现我忘记将脚本包含在我想包含在实时站点中的文件中。

Also, you should try this:另外,你应该试试这个:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));

Here is the code with line 156, it has try and catch above it这是第 156 行的代码,它上面有 try and catch

    /// <summary>
    /// Execute a SQL Query statement, using the default SQL connection for the application
    /// </summary>
    /// <param name="query">SQL query to execute</param>
    /// <returns>DataTable of results</returns>
    public static DataTable Query(string query)
    {
        DataTable results = new DataTable();
        string configConnectionString = "ApplicationServices";

        System.Configuration.Configuration WebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/Web.config");
        System.Configuration.ConnectionStringSettings connString;

        if (WebConfig.ConnectionStrings.ConnectionStrings.Count > 0)
        {
            connString = WebConfig.ConnectionStrings.ConnectionStrings[configConnectionString];

            if (connString != null)
            {
                try
                {
                    using (SqlConnection conn = new SqlConnection(connString.ToString()))
                    using (SqlCommand cmd = new SqlCommand(query, conn))
                    using (SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd))
                        dataAdapter.Fill(results);

                    return results;
                }
                catch (Exception ex)
                {
                    throw new SqlException(string.Format("SqlException occurred during query execution: ", ex));
                }
            }
            else
            {
                throw new SqlException(string.Format("Connection string for " + configConnectionString + "is null."));
            }
        }
        else
        {
            throw new SqlException(string.Format("No connection strings found in Web.config file."));
        }
    }
  1. If you are facing this problem (Enter windows + R) an delete temp(%temp%)and windows temp.如果您遇到此问题(输入 windows + R),请删除 temp(%temp%) 和 windows temp。
  2. Some file is not deleted that time stop IIS(Internet information service) and delete that all remaining files .某些文件没有被删除,此时停止 IIS(Internet 信息服务)并删除所有剩余的文件。

Check your problem is solved.检查您的问题是否已解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当前Web请求的执行期间发生未处理的异常。 型号兼容性无法检查 - An unhandled exception occurred during the execution of the current web request. Model compatibility cannot be checked 如何修复“在执行当前 Web 请求期间发生未处理的异常。” - How to fix "An unhandled exception occurred during the execution of the current web request. " 在执行当前Web请求期间生成了未处理的异常。[HttpAntiForgeryException] - An unhandled exception was generated during the execution of the current web request.[HttpAntiForgeryException] 在执行当前Web请求asp net的过程中生成了未处理的异常 - an unhandled exception was generated during the execution of the current web request asp net 当前Web请求“Ненайденуказанныймодуль”的执行期间发生未处理的异常 - An unhandled exception occurred during the execution of the current web request, “Не найден указанный модуль” 当前Web请求执行期间发生未处理的异常 - An unhandled exception occurred during the execution of the current web request 获取“在执行当前Web请求期间生成了未处理的异常。” 我的MVC UserManagementController中的错误 - Getting 'An unhandled exception was generated during the execution of the current web request.' Error in my MVC UserManagementController 处理请求时发生未处理的异常。 ASP.NET 核心MVC - An unhandled exception occurred while processing the request. ASP.NET Core MVC 处理请求时发生未处理的异常。(在 asp.net 上排序的其余 api) - An unhandled exception occurred while processing the request.(Rest api sorting on asp.net) Sitecore MVC-在执行当前Web请求期间生成了未处理的异常 - Sitecore MVC - An unhandled exception was generated during the execution of the current web request
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM