Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7504419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:33:48+00:00 2026-05-29T21:33:48+00:00

I get some strange behaviour when I load data via my custom VirtualPathProvider. It

  • 0

I get some strange behaviour when I load data via my custom VirtualPathProvider.
It might be important to mention, that I am trying to use this view as a layout.

public class MyVirtualPathProvider : VirtualPathProvider
{
    public MyVirtualPathProvider()
        : base()
    {

    }

    public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) 
    {
        if ((virtualPath.StartsWith("/Path/") ||
            virtualPath.StartsWith("~/Path/")) && virtualPath.EndsWith(".cshtml"))
        {
            String name = virtualPath.Replace("/Path/", "").Replace(".cshtml", "");
            Uri uri = new Uri("http://www.example.com/Handler.ashx?path=" + name);
            return new WebCacheDependency(uri.ToString());
        }

        return base.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
    }

    public override bool FileExists(string virtualPath)
    {
        if ((virtualPath.StartsWith("/Path/") || 
            virtualPath.StartsWith("~/Path/")) && virtualPath.EndsWith(".cshtml"))
            return true;

        return base.FileExists(virtualPath);
    }

    public override VirtualFile GetFile(string virtualPath)
    {
        if (virtualPath.StartsWith("/Path/") || virtualPath.StartsWith("~/Path/"))
            return new TemplateVirtualFile(virtualPath);

        return base.GetFile(virtualPath);
    }
}

I also have implemented a custom (dummy) CacheDependency

public class WebCacheDependency : CacheDependency
{
    public WebCacheDependency(String url)
    {
        this.SetUtcLastModified(DateTime.UtcNow);
    }
}

Now there are two things that don’t work. First, all loaded views are being cached and secondly, code inside the file (@Html.ActionLink … etc.) does not work, It just gives an error “assembly missing”.

Has anyone an idea how to remedy those two problems?

There’s already a solution of the second problem (link) however I really don’t get it how this problem can be solved inside the FileExists method.

Thank you!

Update: An image of the error message
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:33:50+00:00Added an answer on May 29, 2026 at 9:33 pm

    Do you have your web.config properly setup for Razor? If you don’t specify the pageBaseType of WebViewPage you won’t have access to the ViewBag as its not in the default base type, WebPageBase.

    Your web.config should look something like this:

    <system.web.webPages.razor>
      <pages pageBaseType="System.Web.Mvc.WebViewPage">
        [...]
      </pages>
    </system.web.webPages.razor>
    

    Note the pageBaseType attribute. More info here: http://msdn.microsoft.com/en-us/library/system.web.webpages.razor.configuration.razorpagessection.pagebasetype(v=vs.99).aspx

    By default, the default value for PageBaseType is System.Web.WebPages.WebPage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get some XML data with LINQ, but running into a
I'm trying to get some code working that a previous developer has written. Yep,
I'm trying to learn python and have encountered some strange behaviour. I am experimenting
We use varnish as our load balancer (among other things) but we get some
I've run into some strange behaviour when trying to obtain the current stack pointer
On some computers I have the strange effect that UdpClient will not send data
I am trying to get some accurate runtime comparisons of PHP vs Python (and
I need to get some information that is contained in the MFT on a
I need to get some AVI animations for use with the Borland VCL TAnimate
Could I get some confirmations from the community that I'm not going mad, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.