如何在基于Web的应用程序中打开此文档并获得点击数? [英] How to open this document in the web-based application and get the count of hits on it?

查看:84
本文介绍了如何在基于Web的应用程序中打开此文档并获得点击数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是ASP.NET的新开发人员,我正在尝试开发一个名为有用的库"的页面,其中将包含许多内容,例如有用的演示文稿和pdf文档.我在服务器中有一个名为(有用资源)的文件夹,并将所有这些有用的演示文稿和文档放在其中.我的数据库中有下表:

I am a new ASP.NET developer and I am trying to develop a page called Useful Library that will contain many things such as useful presentations and pdf documents. I have a folder in the Server called (Useful Resources) and I put all those useful presentations and documents in it. I have the following table in my database:

UsefulResources Table: ID, Category, Title, URL, Uploaded Date, Hits



设计该表的原因是为了组织资源并计算文档链接上的点击数.我实现了它,并在页面中很好地显示了它.但是,当我单击其中一个链接时,出现以下错误,并且我不知道为什么:
404-找不到文件或目录.
您要查找的资源可能已被删除,名称已更改或暂时不可用.


点击的链接将如下所示:
http://www.pmvt.com/msa/pssp/UsefulResourcesCountHits.asp?ID = 1& link = Useful%20Resources/Electrical%20safety.ppt [



The reason of designing this table is to organize the resources and count the hits on the link of the document. I implemented it and it shows well in the page. However, when I click on one of the links, I got the following error and I don''t know why:
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.


The clicked link will be like this:
http://www.pmvt.com/msa/pssp/UsefulResourcesCountHits.asp?ID=1&link=Useful%20Resources/Electrical%20safety.ppt[^]

**Could you please help me in this?**

My ASP.NET Code:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        DataSourceID="Sql_Categories" ShowHeader="False" Width="100%"
        BorderStyle="None" GridLines="None">
        <Columns>
            <asp:TemplateField HeaderText="Category" SortExpression="Category">
                <ItemTemplate>
                <a id=''<%# (Eval("Category").ToString()) %>''> </a>
                <br />
                    <asp:Label ID="Label1" runat="server" Text=''<%# Eval("Category") %>''
                        style="font-weight: bold; font-size: 14px"></asp:Label>
                <br />
                    <asp:SqlDataSource ID="Sql_Reports" runat="server"
                        ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
                        SelectCommand="SELECT [ID], [Title], [URL], [UploadedDate] FROM [UsefulResources] WHERE ([Category] = @Category) ORDER BY [UploadedDate] DESC">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="Label1" Name="Category" PropertyName="Text"
                                Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
                        CellPadding="4" DataSourceID="Sql_Reports" ForeColor="#333333" GridLines="None"
                        Width="100%">
                        <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                        <RowStyle BackColor="#E3EAEB" />
                        <Columns>
                            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title">
                                <ItemStyle HorizontalAlign="Center" Wrap="False" Width="100px" />
                            </asp:BoundField>
                            <asp:HyperLinkField DataNavigateUrlFields="ID,URL"
                                DataNavigateUrlFormatString="Useful Resources/UsefulResourcesCountHits.asp?ID={0}&link=Useful Resources/{1}"
                                DataTextField="Title" HeaderText="Title" />
                            <asp:BoundField DataField="UploadedDate" DataFormatString="{0:MMM yyy}" HeaderText="UploadedDate"
                                SortExpression="UploadedDate">
                                <ItemStyle HorizontalAlign="Center" Wrap="False" Width="100px" />
                            </asp:BoundField>
                        </Columns>
                        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                        <EditRowStyle BackColor="#7C6F57" />
                        <AlternatingRowStyle BackColor="White" />
                    </asp:GridView>
                <div align="right"><a href=''#Top''>Back to Categories</a></div>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="Sql_Categories" runat="server"
        ConnectionString="<%$ ConnectionStrings:testConnectionString %>"

                SelectCommand="SELECT DISTINCT [Category] FROM [UsefulResources]">
    </asp:SqlDataSource>

推荐答案

ConnectionStrings:testConnectionString%> SelectCommand ="SELECT [ID],[Title],[URL],[UploadedDate]来自[UsefulResources]在哪里([Category] ​​= @Category)ORDER BY [UploadedDate] DESC"> < SelectParameters> < asp:ControlParameter ControlID ="Label1" Name =类别" PropertyName ="Text" 输入="String"/> </SelectParameters> </asp:SqlDataSource> < asp:GridView ID ="GridView2" runat =服务器" AutoGenerateColumns ="False" CellPadding ="4" DataSourceID ="Sql_Reports" ForeColor =#333333" GridLines ="None" 宽度="100%"> < FooterStyle BackColor =#1C5E55" Font-Bold ="True" ForeColor ="White"/> < RowStyle BackColor =#E3EAEB"/> <列> < asp:BoundField DataField ="Title" HeaderText ="Title" SortExpression ="Title"> < ItemStyle Horizo​​ntalAlign ="Center" Wrap ="False" Width ="100px"/> </asp:BoundField> < asp:HyperLinkField DataNavigateUrlFields ="ID,URL" DataNavigateUrlFormatString =有用的资源/UsefulResourcesCountHits.asp?ID={0}&link=有用的资源/{1}" DataTextField =标题" HeaderText =标题"/> < asp:BoundField DataField ="UploadedDate" DataFormatString ="{0:MMM yyy}" HeaderText ="UploadedDate" SortExpression ="UploadedDate"> < ItemStyle Horizo​​ntalAlign ="Center" Wrap ="False" Width ="100px"/> </asp:BoundField> </列> < PagerStyle BackColor =#666666" ForeColor ="White" Horizo​​ntalAlign ="Center"/> < SelectedRowStyle BackColor =#C5BBAF" Font-Bold ="True" ForeColor =#333333"/> < HeaderStyle BackColor =#1C5E55" Font-Bold ="True" ForeColor ="White"/> < EditRowStyle BackColor =#7C6F57"/> < AlternatingRowStyle BackColor ="White"/> </asp:GridView> < div align ="right">< a href =''#Top''>返回类别</a></div> </ItemTemplate> </asp:TemplateField> </列> </asp:GridView> < asp:SqlDataSource ID ="Sql_Categories" runat =服务器" ConnectionString =<%
ConnectionStrings:testConnectionString %>" SelectCommand="SELECT [ID], [Title], [URL], [UploadedDate] FROM [UsefulResources] WHERE ([Category] = @Category) ORDER BY [UploadedDate] DESC"> <SelectParameters> <asp:ControlParameter ControlID="Label1" Name="Category" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource> <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="Sql_Reports" ForeColor="#333333" GridLines="None" Width="100%"> <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#E3EAEB" /> <Columns> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title"> <ItemStyle HorizontalAlign="Center" Wrap="False" Width="100px" /> </asp:BoundField> <asp:HyperLinkField DataNavigateUrlFields="ID,URL" DataNavigateUrlFormatString="Useful Resources/UsefulResourcesCountHits.asp?ID={0}&link=Useful Resources/{1}" DataTextField="Title" HeaderText="Title" /> <asp:BoundField DataField="UploadedDate" DataFormatString="{0:MMM yyy}" HeaderText="UploadedDate" SortExpression="UploadedDate"> <ItemStyle HorizontalAlign="Center" Wrap="False" Width="100px" /> </asp:BoundField> </Columns> <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#7C6F57" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView> <div align="right"><a href=''#Top''>Back to Categories</a></div> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:SqlDataSource ID="Sql_Categories" runat="server" ConnectionString="<%


ConnectionStrings:testConnectionString%>" SelectCommand ="SELECT DISTINCT [类别]来自[UsefulResources]"> </asp:SqlDataSource>
ConnectionStrings:testConnectionString %>" SelectCommand="SELECT DISTINCT [Category] FROM [UsefulResources]"> </asp:SqlDataSource>


对于ASP.NET的新手来说,您正在尝试做一些非常复杂的事情.如果您是新手,肯定没有人在使用它,您可以选择一个更简单的任务?

该错误表示它的意思.如果需要命中计数,则需要转到一个页面,该页面提供文件的字节,并存储有人请求的文件.直接链接将不允许您在请求时运行代码.无论哪种方式,如果遇到该错误,则文件都不在该位置的站点上,或者未配置IIS来提供该文件.
For someone who is new to ASP.NET, you''re trying to do something quite complex. If you''re new, surely no-one is using this, and you could choose a simpler task ?

The error means what it says. If you want a hit count, you need to go to a page that serves the bytes of the file, and stores that someone requested it. A direct link will not allow you to run code when it''s requested. Either way, if you get that error, the file is not on your site in that location, or your IIS is not configured to serve it.


这篇关于如何在基于Web的应用程序中打开此文档并获得点击数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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