In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to solve the errors caused by ASP.NET MVC namespaces". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to solve the errors caused by ASP.NET MVC namespaces.
Create a new Asp.net mvc5 project using VS2012 and change the project's namespace name (Src to UXXXXX), which results in the following error
After the beginning, it was the problem that the namespace in the properties of the project had not been changed, but when I renamed it, I changed the global name, and the namespaces of all files have been changed.
I thought about it later and searched for "Src" in the solution. In addition to the js script referenced on the page, I also found that the Views/web.config file contained "Src".
The code automatically generated by Asp.net MVC is as follows. You can see that the automatically generated code merges the namespaces introduced in Views/web.config into the View page code. I guess the reason for this is that the namespaces set in views/web.config can be used directly in the View template under the namespaces set in the configuration file.
Do an experiment (make sure that the System.Text namespace is not referenced in Views/web.config):
Empty all the contents of the View (including _ ViewStart.html, _ Layout.cshtml, etc.)
If you empty the views/Login.schtml content and write it to the following content, then regenerate it and view it in the browser, the following error occurs (because StringBuilder does not reference the namespace System.Text)
There are two solutions.
Import System.Text in Views/web.config (the namespace you need) use the full type name (System.Text.StringBuilder) in the view template to use StringBuilder
@ {DateTime d = DateTime.Now / / reference System.Text namespace must be set in the Views/web.config configuration file, otherwise an error will be reported / after the namespace is referenced in the configuration file, there is no automatic completion in the view template, and VS will not check whether the type exists at compile time / / if the type does not exist or enter an error Errors are reported only at run time, StringBuilder sb = new StringBuilder () / / use the complete type directly in the view template without setting it in the configuration file / / although VS has autocomplete function, it also does not check the type line at compile time / / the error System.Text.StringBuilder sb = new System.Text.StringBuilder () is reported only at run time; sb.Append ("1,"); sb.Append ("2,") } @ d@sb.ToString () so far, I believe you have a better understanding of "how to solve the errors caused by ASP.NET MVC namespaces". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.