Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
432 views
in Technique[技术] by (71.8m points)

asp.net mvc - Why don't my Html Helpers have intellisense?

I can't get intellisense for my own html helpers. My CustomHtmlHelpers.cs looks like this:

using System.Web.Mvc;
using System.Text;
using System.Web;

    namespace laget.Web.Helpers
    {
        public static class CustomHtmlHelpers
        {
            //MY HELPERS
        }
    }

and in my Web.config:

    <pages>
      <namespaces>
        <add namespace="laget.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages"/>
        <add namespace="System.Web.Helpers" />
      </namespaces>
    </pages>

If I put <@using laget.Web.Helpers> in my view, I get the intellisense issue fixed.

Should it not be enough with the code in Web.config?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Sometimes it doesn't seem to work right away. Try closing the .cshtml file, and re-opening it. Then if that doesn't work, try restarting Visual Studio. Also make sure you actually compiled your project, intellisense won't work with non-compiled helpers.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...