简体   繁体   English

C#/ ASP.NET:代码更改后,HREF路径未更新

[英]C#/ASP.NET: HREF Path not updating after code-behind change

I'm working on a website for my company that will allow us to house and distribute .XML and .HTM Perfmon Templates. 我正在为我公司的网站工作,这将使我们能够容纳和分发.XML和.HTM Perfmon模板。 The site consists of a creator tool that is used to create the templates and a repository where the templates are stored. 该站点由用于创建模板的创建器工具和用于存储模板的存储库组成。 When a user hits the repository site and chooses to view either XML or HTM Templates, the the page looks in a directory (~/Perfmon Templates/) and lists out all of files of the type that the user specified. 当用户访问存储库站点并选择查看XML或HTM模板时,页面将在目录(〜/ Perfmon Templates /)中查找并列出用户指定类型的所有文件。 It creates a hyperlink to the file and parses the file to list the counters that are included in the template. 它创建到文件的超链接,并分析文件以列出模板中包含的计数器。 This is all working without issue on my local machine. 这一切在我的本地计算机上都没有问题。 Yesterday, I published the website to an IIS7 server running ASP.NET 4.6. 昨天,我将该网站发布到了运行ASP.NET 4.6的IIS7服务器上。

After publishing, while testing the site, I found that the hyperlinks in the repository were no longer working. 发布后,在测试站点时,我发现存储库中的超链接不再起作用。 This was because the path changed ever so slightly from ~/Perfmon Templates/ to ~/Perfmon/Perfmon Templates. 这是因为该路径从〜/ Perfmon Templates /更改为〜/ Perfmon / Perfmon Templates,所以变化很小。 So I opened up the C# code behind for the repository webpage and changed the relative path for the hyperlink to reflect the path changes. 因此,我打开了存储库网页的C#代码,并更改了超链接的相对路径以反映路径更改。 After copying the .cs code behind file and the .aspx page file back up to the server, I ran the test again and found no change in the hyperlink path. 将文件后面的.cs代码和.aspx页面文件复制回服务器后,我再次运行测试,发现超链接路径中没有变化。

My first thought, at this point, was that the C# file must be getting cached somewhere so I tried a CTRL+F5 on the browser to see if that corrected the issue. 此时,我的第一个想法是必须将C#文件缓存到某个位置,因此我在浏览器上尝试了CTRL + F5,以查看是否可以解决此问题。 It did not. 它没。

So I went back to the local copy that I have on my machine and tried to run the updated page in debug mode on my local machine. 因此,我返回到计算机上的本地副本,并尝试在调试模式下在本地计算机上运行更新的页面。 I set break points where the hyperlinks are created and insured that the relative path on the hyperlinks was pointing to the updated location. 我在创建超链接的地方设置断点,并确保超链接上的相对路径指向更新后的位置。 I then started debugging but found that the site was not processing my breakpoints at all regardless of whether I chose to start debugging from the Debug menu or if I clicked the Play button to start it. 然后,我开始调试,但是发现该站点根本不处理断点,无论我是选择从“调试”菜单中启动调试还是单击“播放”按钮来启动它。

After that didn't work, I tried commenting out all of the lines of C# code that control the creation of the hyperlinks and restarted Debugging. 在那行不通之后,我尝试注释掉了控制超链接创建的C#代码的所有行,并重新启动了Debugging。 To my shock and surprise, the old hyperlink path was still present on the page. 令我震惊和惊讶的是,页面上仍然存在旧的超链接路径。

It seems like the page is not even reading the C# code-behind file, but I know it has to be getting the code from somewhere and that code-behind file is the only location in my solution where the hyperlink path is even mentioned. 该页面似乎甚至没有读取C#代码隐藏文件,但我知道它必须从某处获取代码,而代码隐藏文件是我的解决方案中唯一提到超链接路径的位置。

Here is the code from the C# code behind file that controls the creation of the hyperlink. 这是C#代码隐藏文件中的代码,用于控制超链接的创建。 I'm not sure it will help resolve the problem though since I have commented almost all of it out at one point and it still didn't make a difference. 我不确定它是否会帮助解决问题,尽管由于我已经将几乎所有问题都注释掉了,但仍然没有任何改变。

HyperLink fileLink = new HyperLink();
        fileLink.NavigateUrl = "~/Perfmon/Perfmon Templates/" + f.Name.ToString();
        fileLink.Text = f.Name.ToString();
        fileLink.Visible = true;
        fileLink.Style.Add("color", "#111111");
        fileLink.Style.Add("text-decoration", "none");

        string perfCounterList = string.Join(Environment.NewLine, counters);
        string perfCounters = Regex.Replace(perfCounterList, @"\r\n?|\n", "<br />");
        //dt.Rows.Add(Count, "<a href='/Perfmon/Perfmon Templates/" + f.Name.ToString() + "'>" + f.Name.ToString() + "</a>", perfCounters);
        dt.Rows.Add(Count, fileLink, perfCounters); 

Can anyone please point me to where I am going wrong? 谁能指出我出问题的地方吗? I've checked the web.config file to insure that Debugging is enabled. 我已经检查了web.config文件,以确保启用了调试。 I've tried the CTRL + F5 trick to see if it was browser cache that was interfering. 我试过了CTRL + F5技巧,看是否是浏览器缓存干扰了。 Neither of those things seem to help at all. 这些东西似乎都没有帮助。 Is there something else I can try? 还有什么我可以尝试的吗?

问题是由于更改了构建输出目录并且没有将构建文件从新的构建位置移动到服务器而引起的。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM