To extract the referenced .js file paths from the content of a cshtml file (Razor view), you can use C# with regular expressions. Cshtml files may contain references to .js files using various HTML elements, such as script tags or script bundles.

Here’s a C# code snippet to extract the referenced .js file paths from a cshtml content:

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
    static void Main()
        // Replace "path/to/your/cshtml/file.cshtml" with the actual path to your cshtml file.
        string cshtmlFilePath = "path/to/your/cshtml/file.cshtml";

        string cshtmlContent = System.IO.File.ReadAllText(cshtmlFilePath);
        List<string> referencedJsFiles = ExtractReferencedJsFiles(cshtmlContent);

        Console.WriteLine("Referenced .js files:");
        foreach (string jsFile in referencedJsFiles)

    static List<string> ExtractReferencedJsFiles(string cshtmlContent)
        List<string> jsFiles = new List<string>();
        // Using regex to find references to .js files within the cshtml content.
        // This regex assumes that .js file references are inside script tags or bundles.
        MatchCollection matches = Regex.Matches(cshtmlContent, @"(?<=src="")[^""]*\.js(?="")|(?<=bundles\.Add\("")[^""]*\.js(?="")");
        foreach (Match match in matches)
            string jsFileName = match.Value;

        return jsFiles;

Please replace "path/to/your/cshtml/file.cshtml" with the actual path to your cshtml file. The code will read the content of the cshtml file and extract the referenced .js file paths using regular expressions.

Keep in mind that this method may not cover all possible variations of .js file references in cshtml files. If your cshtml files use different conventions for referencing .js files, you may need to adjust the regular expression accordingly. Additionally, for more robust parsing and handling of cshtml files, you can consider using specialized libraries like AngleSharp