How do you understand "No control over your namespaces" namespace issue, quoted from,
http://reddnet.net/code/asp-net-web-site-vs-web-application-project-part-2/
Here are more background:
one of the cons of web site project type of VSTS 2005 is, my confusion is what exactly means "no control over your namespace"?
No control over your namespaces. Sure, you can manually add namespaces to pretty much anything, but visual studio will fight you every step of the way. With generated code such as ADO.NET DataSets and such, this gets very hard to control. Eventually you will give up and just let VS put everything in the default namespace. In large applications this gets very annoying, especially if you like a well structured application.
Appreciate if anyone could show a sample here.
Just test this: create a Web Application and a Web Site, then take a look to the namespaces created into the Default.aspx.cs:
WebSite: has no namespace
WebApplication: has namespace
When you have a very big application it's impossible to find your classes without namespaces.
Now create a DataSet:
WebSite: no .Designer.cs created -> namespace will be created automatically on the fly
WebApplication: .Desinger.cs created with proper namespace.
George, Web Sites are not specific to VSTS. That's a normal Visual Studio feature, haunting us since Visual Studio 2005.
Also, see https://stackoverflow.com/questions/237664/web-site-vs-asp-net-web-application-in-visual-studio.
Related
I'm working on a project and I'm fairly new to ASP (not to C#).
We have a solution for a whole web application consisting of several projects and I want to add a couple of ASP WebForms to one of the projects. However, when I right click on the folder of the project and select Add element, it only shows me VB options.
But if I try to add other project to the solution, then all the other options are displayed.
The project in which I'm trying to add new Web Forms is entirely written in C#, so I don't know well what's happening back there. I cannot stop thinking it might a dumb mistake I'm making.
I'm working under Visual Studio 2017 and .NET Framework 4.7.2. It is there some kind of requirement I'm missing?
Thanks in advance for your time and sorry if it's something simpler, but I really don't know what's going on here.
As noted, this looks like that one application was created as a vb.net application.
You can freely consume say c# code (assemblies) in a vb.net project. And of course you can do the reverse.
However, for a given project created? You can't at the IDE level mix vb.net and c# code modules and general writing of code between c# and vb.net.
However, as in your example, you can certainly "include" multiple mixes of vb.net and c# projects into one same project. However, each part and section will still be limited to the chosen language used to build that application. So mixing is allowed at the project level - but not below that level.
So, it looks to be that project was created and developed with vb.net. You can't really change that unless you create a new project as c#, and then pull in all the forms, code etc. and re-factor the vb.net to c#.
So your practical project language choice is really limited to the project level. Multiple projects of different languages can be included overall, but each part will remain in its given language choice. The fact that you can do this in .net is amazing enough, but that language choice is really set in stone at the project level.
While you're figuring it out, if you need to press on and get some work done just copypaste another file that is already in the solution, and is of the type you require, then change its contents. This can usually be a time saver anyway, as the "new product" form isn't so hugely different from the "new user" form, just a different bunch of labels and textboxes..
There is nothing magical about the "add new item" dialog, it just adds files with pre filled templated content. For a cs class (for example) that's a file that basically has a detected namespace and the name you specified in the add dialog. You could even add a VB file of the type you want and then change the contents and name of the file to be right for C# - it would essentially be adding a couple of curly brackets and changing the case of Namespace and Class (and maybe changing Imports to using)
You cannot mix languages in the same assembly in .Net. Create another assembly you can put your C# code in there and use it in the VB.Net project.
Or use VB.Net it's not that bad.
I'm trying to generate an xml sitemap for published Umbraco content. Ideally I'd like to access UmbracoHelper.TypedContentAtRoot() or something similar that gives easy access to published items. I need to access it outside the web solution, inside a supporting assembly where I'm generating xml sitemaps and sitemap index for dynamic content outside the direct control of Umbraco.
Any ideas about the easiest way to go about this? I've tried referencing various Umbraco assemblies and digging into what's readily available but haven't found anything immediately useful yet.
I have stumbled across
UmbracoContext.Current.Application.Services.ContentService.GetRootContent()
but this seems to require a much deeper understanding about how Umbraco content works under the covers in order to drill down to extract published content for me to index.
Can anyone point me in the right direction? Thanks in advance!
Assuming the DLL you are creating is going to be using IN the umbraco site, you will be able to access UmbracoContent.Current in your classes, as long as you've got a reference to the Umbraco.Core package, as Mivaweb states.
If on the other hand you want to access the UmbracoContext from a completely unrelated external application (say an executable file), then that it MUCH harder to do. A few people have got it sort of working, but it's a bit flakey. Usually in this case, you're better off adding some kind of WebAPI controller action that you can call via HTTP from your executable file, so you have full access to Umbraco on the site.
Update:
If you just want to access the typed content, you can get at it by using:
UmbracoContext.Current.ContentCache
This will allow you to do stuff like:
UmbracoContext.Current.ContentCache.GetAtRoot();
Which will get you all of the root content of the cache.
If you have a seperated project where you would like to do Umbraco stuff then go to the nuget package manager and install Umbraco.Core.
This will install only the necessary Umbraco dll's that you then can use.
Then you just need to include the namespace and you are ready to go.
I am working on a Web application project and although I am an experienced Visual Studio developer almost all of that has been in WinForms, console apps, Services, etc. That is, I have very little experience with using VS to develop web pages (Web Forms, asp.net, etc.), however, I am learning how to apply my previous Web page knowledge to VS.
One thing that has been throwing me for a while is how to apply additional CSS files in development, that should not be used in production (because they are already there). Specifically, I am working on a set of pages (DNN module) that is being deployed into a larger website context.
This all works fine, except the VS Web Page Design Editor is nigh useless because it's WYSIWYG rendering is not even remotely close to what the page looks like on the site. I know why this is happening: the site (and DNN) have their own set of CSS files that are getting applied/added to the page.
I know that I could just add those same style sheets to my web page in development (using <link href=...> tags?), however, then the web page would be deployed referencing these CSS files twice (there's a bunch of them too).
So my question is, is there any easy solution to this? Is there some setting somewhere that I can just say "use these additional CSS files in development or in the Design Editor"? (I hHve tried to google this, etc. but I just find dozens/hundreds of articles about how to add or edit CSS in Visual Studio)
Unfortunately I think that may have mis-explained my need somewhat. The issue really is not a development vs production issues, but rather an IDE vs execution issue. When debugging the code or otherwise running it in development, it is still within the DNN test environment we have setup, so it does have the extra file even here.
This is really about the HTML designer, when i am using it it does not have these extra style sheets, so I cannot see what the work I am doing really looks like. Instead, i have to run it every time I want to see whether any change i make looks like it is supposed to. This gets extremely onerous, especially with how slow DNN is to compile and reload.
Hmm, do you have your web project setup to run on IIS instead of IIS Express?
Something I do is often just work in the project then Save and if needed build. Then browse to the Site on my machines IIS instance (right click file in solution explorer and select browse if using ASP.NET Web forms).
Once I have done that I can refresh my page. I also use #if Debug in my code to bypass user login and etc to make round tripping faster...
I wanted to make a small test site using the Metro UI framework (http://metroui.org.ua/)
So, I started up my newly installed Visual Studio 2013 and started a "new website". I added the neccesary css and js and made a very basic masterpage and default.aspx. But here comes the problem: the css does get loaded, but it doesn't get applied. Not in FireFox, not in IE, not in Chrome and not in the "Page Inspector".
It's quite weird, because in my previous VS2012 this same workflow for testing and experimenting with a framework just worked. I really can't find the problem. Maybe it has to do with my new Windows 8.1, my new Visual Basic 2013, maybe an programming error (although that would be very unlikely, since I checked everything).
I also tried installing the framework using NuGet instead of manually adding it. Same result: it does load, but it doesn't get applied.
Anyone knows what's happening here?
Thanks in advance!
According to MetroUI you have to follow 5 simple steps
Create page with HTML5 DOCTYPE
2.Include metro-bootstrap.css
Include metro.min.js (jquery.js required)
Create main container with class .metro
Use markup, as described in the pages of this site
In your posted images I can't find a container with class .metro . I'd really check the sample code from the posted page.
In case I misunderstood anything please let me know!
I'm using Visual Studio 2012 Ultimate in Windows 8.
I'm confused as to how to start an asp.net web page web site. Is it via Visual Studio, by selecting File | New Website | ASP.NET Web Site (Razor v2) or (some other selection) or do I need to create the asp.net web page web site from WebMatrix and, if so, do I need to install WebMatrix separately from Visual Studio, or was it installed as a part of Visual Studio?
Searching for the existence of an app named "WebMatrix" in Windows 8 returned nothing...
UPDATE
Mike, I'm a third of the way through your book and I think it's great.
A couple of nights ago I read where you called braces brackets or vice versa and almost said out loud, "This cat must be a Brit!" I then read the frontispiece where that exact fact is declaimed.
Anyway, I was reading "C# 5.0 in a Nuts Hell" today at lunch, and read: (a llittle context: the Albahari boys are here discussing asp.net MVC) "What you lose over Web Forms is a designer. This makes Web Forms still a good choice for web pages with predominantly static content." (bottom of page 194).
This ("predominantly static content") describes the site I'm going to build to a T: most of the content will be static or simple links to other sites. The only non-static content will be pushpins on a Bing Map, but even these could be viewed as static (depending on one's definition of static), as they will really remain the same superset - the user just selects which subset they want to see at any given time.
The "static electricity" voltage of my site depends also on whether you call a PayPal button, a Twitter window, and rotating Ads to be static, too, I reckon.
Anyway, I said all that to say this: In my situation, would Web FORMS be better than Web PAGES? Pardon me if the rest of your book answers that question, but ... I'm not the most patient cat in the world.
WebMatrix is an IDE - not a development framework. The development framework that it was primarily designed to support is known as the ASP.NET Web Pages framework. However, within Visual Studio, it is known as an ASP.NET Web Site (Razor vx) and as you have discovered is accessible via the New Web Site option.
You do not need to install WebMatrix in order to develop these types of applications. However, WebMatrix offers more choice in terms of templates for Web Pages sites and starts up a lot quicker than VS. On the other hand, WebMatrix doesn't include any debugging tools.
WebMatrix is completely separate from Visual Studio and is not installed with it. If you want to install WebMatrix, you can get it here: http://www.microsoft.com/web/webmatrix/
This might not be the answer to the question, but I just started using WebMatrix and it seems much easier and convenient to use mostly because of the various templates available.