-3

But it does! And it was working yesterday. And not a single thing in my code has changed.


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for TestClass
/// </summary>
public class TestClass
{
    public static string CurrentPage = String.Empty;

    public class Request
    {
        public static void PageName()
        {

            CurrentPage = Path.GetFileNameWithoutExtension(HttpContext.Current.Request.FilePath);
        }
    }
}

Page.cshtml:

@{
}

<div id="subHeader">
    <div class="container">
        <p><span>Viewing:</span> @TestClass.CurrentPage</p>
    </div>
</div>
<main id="main" role="main">

I have no idea what the heck is wrong. Why is VS suddenly complaining of something it's been letting me do for oh I dunno... 1 year?!

username
  • 289
  • 4
  • 19
  • does it complain about `CurrentPage = Path.Get` in .cs or about `@TestClass.CurrentPage` in cshtml? Have you updated nugets or visualstudio recently? – quetzalcoatl Nov 05 '15 at 12:26
  • Try Rebuild All for starters. Are you saying not a single thing changed *that ought to matter*... Or literally, you diff the files and all the zeroes and ones are the same? P.S. This is why you make backups. – 15ee8f99-57ff-4f92-890c-b56153 Nov 05 '15 at 12:28
  • 2
    I would even go so far as to go into all of your projects in the solution and delete the `bin` and `obj` folders manually. Then do a `Clean Solution` and `Build Solution`. I have seen VS do some wonky things. – gmiley Nov 05 '15 at 12:31
  • I did do a Rebuild All. That didn't fix it up though. And @EdPlunkett yes, I mean literally, not a single thing has changed. And I'm not talking about those files alone, I'm talking about the entire project, not a single file or any part of it has changed. – username Nov 05 '15 at 12:52
  • @Quetzalcoatl No, it doesn't complain about `= Path.Get`, and if it did, it shouldn't, because it was working yesterday, and the day before, and weeks before that - and in other projects, months ago. – username Nov 05 '15 at 12:53
  • Is `TestClass` in a separate project from `Page.cshtml`? If it is, ensure that the reference to the project/library containing `TestClass` has no problems. View the reference in `Object Browser` to ensure it looks correct and contains all of the members it should, specifically the `CurrentPage` field. – gmiley Nov 05 '15 at 13:27
  • @gmi It's in the same project. I did however manage to get it working thanks to your previous comment. Deleting the bin folder manually then rebuilding has solved the oroblem – username Nov 05 '15 at 13:30
  • 1
    I will add it as an answer then. Glad it fixed it. – gmiley Nov 05 '15 at 14:20

1 Answers1

2

Ensure that both bin and obj folders under each project within the solution are cleaned. You can do that by manually deleting them from each project. Once they are gone you can try performing a Clean Solution and then a Build Solution.

gmiley
  • 6,531
  • 1
  • 13
  • 25