简体   繁体   English

ASP.NET Web窗体-部署到Azure-“您正在寻找的资源已被删除或暂时不可用。”

[英]ASP.NET Web Forms - Deploying to Azure - “The resource you are looking for has been removed or is temporarily unavailable.”

I'm experiencing an error when I deploy my ASP.NET project to a web app service in Azure. 我将ASP.NET项目部署到Azure中的Web应用程序服务时遇到错误。 I can't replicate it when running my code in the local development environment/web server (IIS). 在本地开发环境/ Web服务器(IIS)中运行代码时,无法复制它。

To give some background, the particular page I'm struggling with is the newest page I've added to the project; 为了提供一些背景信息,我正在苦苦挣扎的特定页面是我添加到项目中的最新页面。 all other pages work fine. 所有其他页面都可以正常工作。 I am doing a bit of query-string passing, but even without passing the query string in the URL, I'm seeing the same error. 我正在做一些查询字符串传递,但是即使没有在URL中传递查询字符串,我也会看到相同的错误。

Error: 错误:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. 您要查找的资源已被删除,名称已更改或暂时不可用。

Here's the code of the page that's not working (.aspx): 这是无法使用的页面代码(.aspx):

<%@ Page Title="Car Photos" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="CarImages.aspx.cs" Inherits="CarImages" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
     <customControls:Header runat="server" heading="Car Photos"></customControls:Header>
    <div class="row">

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings: MYCONNSTRING %>" 
            SelectCommand="SELECT CarImages.CarImage, CarImages.CarName, Cars.CarID, Cars.Model FROM CarImages INNER JOIN Cars ON CarImages.CarID = Cars.CarID WHERE (Cars.CarID = CarImages.CarID)">
                <SelectParameters>
                    <asp:QueryStringParameter Name="CarID" QueryStringField="CarID" Type="Int32" />
                </SelectParameters>
        </asp:SqlDataSource>

        <asp:Label ID="ErrorLabel" runat="server" Text=""></asp:Label>
        <br />
        <br />

        <asp:Image ID="Image1" runat="server" Height="284px" Width="432px"/>
        <br /><br /><br /><br />


    </div>
</asp:Content>

... and the code behind (.aspx.cs): ...以及(.aspx.cs)背后的代码:

public class MyClass
{
    public string ImagePath { get; set; }
    public int Id { get; set; }
    public string Name { get; set; }

}

public partial class CarImages : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string queryStringId = (Request.QueryString["CarID"]).ToString();
        int queryStringIdNum = Int32.Parse(queryStringId);

        SqlConnection con = new SqlConnection("Data Source=SECRETSERVER.database.windows.net;Initial Catalog=SECRETDB;User ID=SECRET;Password=SECRET");
        SqlCommand sql = new SqlCommand(@"SELECT CarID, CarImage, CarName FROM CarImages WHERE CarID = @queryStringIdNum", con);
        sql.Parameters.AddWithValue("@queryStringIdNum", queryStringIdNum);

        con.Open();

        //using(var command = sql)
        //{
        using (var reader = sql.ExecuteReader())
        {
            var list = new List<MyClass>();
            while (reader.Read())
                list.Add(new MyClass
                {
                    ImagePath = reader.GetString(1),
                    Id = reader.GetInt32(0),
                    Name = reader.GetString(2)
                });

            bool isEmpty = !list.Any();

            if (isEmpty)
            {
                ErrorLabel.ForeColor = Color.Red;
                ErrorLabel.Text = "No images currently uploaded. Please check back later";
                Image1.Visible = false;
            }
            else
            {
                ErrorLabel.ForeColor = Color.Green;
                ErrorLabel.Text = "Image found!";
                foreach (var img in list)
                {
                    Image1.ImageUrl = img.ImagePath;
                }
            }
        }
    }
}

I appreciate anyone with a bit of insight. 我感谢任何有见识的人。 I'm struggling to determine what might be causing this, since it works fine in the local webserver (ie building and testing from VS 2017). 我正在努力确定可能是什么原因造成的,因为它在本地Web服务器中运行良好(即从VS 2017构建和测试)。 Thanks all! 谢谢大家!

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. 您要查找的资源已被删除,名称已更改或暂时不可用。

It is a 404 Not Found error. 这是404找不到错误。 It means the page which you requested is not found by your server. 这意味着服务器未找到您请求的页面。 There are two reasons that can cause this problem. 有两个原因可以导致此问题。

  1. The page is not published successfully from your development server. 该页面未从您的开发服务器成功发布。 To check it, you could use FTP to check whether the CarImages.aspx file has been published to Azure Web App. 若要进行检查,可以使用FTP检查CarImages.aspx文件是否已发布到Azure Web App。 You could get the FTP address and use name on Overview panel and set the FTP password on Deployment credentials panel of Azure portal. 您可以在“概述”面板上获取FTP地址和使用名称,并在Azure门户的“部署凭据”面板上设置FTP密码。 If it doesn't exist on Azure Web App server, please redeploy your web application and the issue will be fixed. 如果Azure Web App服务器上不存在此文件,请重新部署您的Web应用程序,此问题将得到解决。

在此处输入图片说明

  1. Please make sure you were accessing the page using the right path. 请确保您使用正确的路径访问页面。 For example, if the CarImages.aspx file is under car folder. 例如,如果CarImages.aspx文件在car文件夹下。

在此处输入图片说明

The path to access this page should be like this, we need to put the folder name in front of the page name. 访问此页面的路径应如下所示,我们需要将文件夹名称放在页面名称之前。

http://yourwebsitename.azurewebsites.net/car/CarImages.aspx?CarID=1

暂无
暂无

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

相关问题 HTTP404。您正在寻找的资源(或其依赖项之一)可能已被删除,名称更改或暂时不可用。 - HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. 您正在寻找的资源(或其依赖项之一)可能已被删除,名称更改或暂时不可用 - The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable ASP.NET MVC 5 中的“资源未找到或暂时不可用”错误 - "Resource not found or temporarily unavailable" error in ASP.NET MVC 5 LDAP服务器不可用。 C#ASP.net - LDAP server unavailable. C# ASP.net ASP.NET Core 3.1 with google signin,nginx反向代理和docker资源暂时不可用 - ASP.NET Core 3.1 with google signin, nginx reverse proxy and docker Resource temporarily unavailable 将ASP.Net Web Forms项目部署到Fedora 24 - Deploying ASP.Net Web Forms project to Fedora 24 Asp.net Web窗体Web应用程序中的Azure AD身份验证 - Azure AD Authentication in Asp.net web forms web application 带有ASP.NET Web窗体的Azure CosmosDB SDK v3 - Azure CosmosDB SDK v3 with ASP.NET Web Forms HttpResponseMessage的通用版本是否已从ASP.NET WebApi中删除? - Has the generic version of HttpResponseMessage been removed from the ASP.NET WebApi? 如何将现有菜单项添加回已删除的ASP.NET C# - How To Add An Existing Menu Item Back Once It Has Been Removed ASP.NET C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM