How to run index.html file in Visual Studio 2015 - asp.net

I have an ASP.NET vNext project with the web start template. I've added a new html file and I wish to run it. However when I go to localhost:1111/index.html I get 404 error. Is there a special configuration in the grunt file?

The HTML file needs to be inside the root of wwwroot folder. You can move the file manually inside the folder and then edit it from inside wwwroot folder. Alternatively set up a Grunt task to copy it to the wwwroot folder using grunt-contrib-copy.
Depending on how you are hosting the project you will then have to enable static files. One way is to use the AspNet Static Files package.
In the project.json add with the beta version you are using (it is there by default in some project templates)
"Microsoft.AspNet.StaticFiles": "1.0.0-beta3",
In the Startup.cs tell the app to use static files (this is also added by default in some templates)
app.UseStaticFiles();
Then this should work...
Also the wwwroot folder is just the default in the starter template, you can change this by looking in the project.json file and changing the webroot property
"webroot": "wwwroot",
In your case you could change it to "." which would set the webroot to be the project folder but I think it is much better to have the "wwwroot" folder which makes it easier to control what can be accessed statically. If you use any languages which needs to be processed into static files, for example SASS and TypeScript, then it is a nice workflow to have the source files outside the webroot and then process them and set the destination to the webroot.

Related

Default .bowerrc pointing to wwwroot/lib in asp 5

Why is this a default point for an empty asp project in the .bowerrc file?
{
"directory": "wwwroot/bower_components"
}
In most cases one would use gulp and create tasks to include only the requested files
gulp.src([
'bower_components/jquery/dist/jquery.min.js',
'bower_components/bootstrap/dist/js/bootstrap.min.js'
])
Thereby creating a cleaner wwwroot. The project.json file even includes an exclude for "bower_components"
It looks like it initially was outside of the wwwroot folder, but developers who weren't used to this workflow (ie. using Grunt/Gulp to copy the relevant files) were getting confused. So they changed it to be inside the wwwroot folder.
Scott Hanselman has a good post about why they did this, and how to change it back to be being outside ...
http://www.hanselman.com/blog/ControlHowYourBowerPackagesAreInstalledWithAGulpfileInASPNET5.aspx

Install components via Bower without SSL in ASP.NET 5 Starter Web project

Due to corporate proxy issues I am unable to download components via Bower using https.
I know that normally you can get around this by adding
"registry": "http://bower.herokuapp.com"
to the .bowerrc file, but I can't seem to find it anywhere.
Please note that I haven't had Bower installed locally (as I am not intended to). I got bower.json from using the new ASP.NET 5 starter Web Project which has popular tools like Grunt and Bower built-in.
I wonder where this file is, or if there is any other way to replace https with http in the download url?
Update
I had to create the .bowerrc file manually and placed it inside the project root.
{
"directory": "wwwroot",
"registry": "http://bower.herokuapp.com"
}
Make sure you have wwwroot there as the directory. Doing this the output will now show with http.
However, this still doesn't resolve my problem - Bower still cannot download anything, nor can nuget. This is really strange 'cause if I create a normal web project using VS2015, nuget works fine...
The .bowerrc file can be located in one of the following:
Local .bowerrc located in the current working directory
All .bowerrc files upwards the directory tree
.bowerrc file located in user’s home folder (%USERPROFILE%)
bowerrc (without the dot) file located in %APPDATA%/bower/config
But setting the bower registry URL is probably not enough as bower will still need the https protocol in order to fetch package content from Github.

mvc which files are needed for deployment?

I've been working with webforms and recently started to work with mvc. With webforms, when we use to push to the qa/prod server, we alway copied over the files. leaving behind the .cs files, so just the .aspx, bin folder, along with associated js/css files would go.
with mvc, if we are copying the directory over from our pc (where we develop), what files are needed, do we need the .cshtml files for example? I just want to avoid having to push all the files if they are not needed.
They are definitely not all required. What you are going to want to do is setup a way to publish, this ranges from doing a "bin deploy" to feeding in ftp settings and using a "single click deploy" approach.
What it all boils down to though is this. You will need
A bin folder with every relevant .dll
A content folder with relevant images and css files
A script folder with relevant .js scripts
A views folder with nested folders for views with relevant .cshtml files
A .webconfig file in the views folder and also one at the very root
The packages.xml file at the very root
The global.asax file with markup pointing to the application starting in global.asax.cs
What this excludes is every single .cs file. These will all be composed into your projects .dll. So if you are developing FunWebApp, then all your c# will be rolled into FunWebApp.dll in your bin folder.
Use the Visual studio "Publish" option available on your UI Project. This will generates all the required files you neeeds includes, bin folder, Views folder(which will have the .cshtml files),Content folder,Script folder, Config file(web.config) etc.
Right click on your project and select "Publish". You will be shown a wizard where you can define what kind of publish you want. You have different options like FTP, File system etc.
You will not see the Controllers folder / Other class files because code inside that folder is compiled to your assembly which is in the Bin folder

Bluimp Backload folder reference issue with virtual directories

I am working on a solution which has two projects in it. One is a virtual app which works in another. The first application is the panel and the second is the website. First application can be accessed with "localhost:10001/panel" and the second with "localhost:10001". You see, I created a virtual path for the first app to work under the second one in Visual Studio and they work great that way.
The problem I am having now is about the file uplaod system, "Blueimp's jQuery-File-Upload" plugin and as backend using "Backload". I must say that these work great on a standalone project. That's why I decided to continue the project using these.
But when it comes to a setup which I explained below, I cannot access the files I upload. I installed fileupload system in the panel project, which is accessed as "localhost:10001/panel" so when I leave the default web.config configuration for backload (default is "~/files"), all files are uploaded to the "localhost:10001/panel/files" path. And after the upload when I refresh the page, all uploaded file links are referencing "localhost:10001/files/" without the "panel" folder.
In BackLoad web.config notes how to change and use root upload folders are explained like that
filesRoot: // Root upload folder. If the value starts with '~/' (e.g. ~/files) the path is relative to the web root, otherwise set an absolute local path (e.g. d:/files) [Default: "~/Files"].
I understand that having "~/" at the beggining of a folder reference shows the project's root. But I can't figure out how to reference the upload folder, instead of the default "~/files", to upload and access all files from the second project's root. When I need to reference folder between these two projects I simple use "../", or "/" to access the second project's (site) root. But doing that in "filesRoot" attribute of BackLoad config settings, all file references are starting "///file....." and shows a local path in the computer.
I simply want to upload and access the files from the "localhost:10001/files" location when I upload files from the panel. Now, I cannot even use the "localhost:10001/panel/files" path because files are uploaded to "panel/files" folder, but are accessed from "files" folder with default settings.
BTW: I am using BackLoad's WebForms Example on this project, and this is a Web Forms project.
I ended up using Files folder as a temp folder. At the time of submit, I move the file which is uploaded in Files folder, to the folder of my need. And the problem is solved.
Thanks anyway...

How to prevent an html-template sub-folder from being refreshed during build?

I placed my AMFPHP folder inside my htmltemplate project folder, but now everytime i build it wants to 'refresh' the folder which takes forever. Is there a way to set it so that folder does not refresh each time? I put the AMFPHP folder in there so I can have a unique copy for my debug builds and leave the production build one alone.
I'm not sure what you mean by 'refresh'
The HTML-Template folder is just a template. During build all files/folders in the template folder are copied to the bin-debug (or bin-release) folder. Is this 'copy' the refresh your talking about?
If you don't want these files copied over every time; just put them in your bin-debug / bin-release folders directly instead of the template folder.
If your AMFPHP folder contains config files; and nothing else, then you probably don't need those files in the html-template, bin-debug, or bin-release folders. You can compile them into the SWF using the services compiler argument.
There is also a setting in the Flash Builder Project Properties that may help. Under Flex Compiler, uncheck 'copy non-embedded files to output folder'. However, I think this relates to files int he source directory; not the HTML Template directory.
Does any of this help?

Resources