Properly publishing/deploying a blazor project to github pages - c#

I'll start this by saying I'm definitely working a bit above my paygrade here. I'll be doing my best to describe this problem and make it easiest to answer.
I've made a Blazor project in Visual Studio and this is connected to the GitHub repository here in the gh-pages branch. After reading Blazor's hosting and deploying guide here, I published the project in Visual Studio and copied the files in the /bin/Release/netstandard2.0/publish/ChargeLearning/dist folder to the root of the repository resulting in a repository with this file structure:
ChargeLearning
ChargeLearning
_content
_framework
css
sample-data
ChargeLearning.sln
index.html
At this point I think am already neck-deep in bad practice.
Regardless, attempting to load the index.html results in 404 errors in the console for most of the files in the html header like bootstrap (as the blazor deploying guide warned).
So I followed the instructions there as best as I could, attempting to implement this single page app (SPA) fix for gh-pages linked in the guide.
I added the 404.html file to the ChargeLearning repository now when I load the page it displays just one 404 error, for the blazor.webassembly.js file.
I then add the redirect script from the SPA fix to my willthamic.github.io repository which when I open the direct url to the blazor.webassembly.js file seems to redirect properly but github shows my home page and I now realize that it has been severely mangled and now images aren't loading.
I feel like I am doing a lot of things wrong here which makes it difficult to isolate and solve a single problem at once.
If you have specific advice on how to properly deploy this or even small things on how to do what I'm trying to do a little more properly I would greatly appreciate it.
Thanks in advance.

The blazor.webassembly.js file was stored in a directory beginning with an underscore (_framework), which github's jekyll ignores when deploying the website. After adding a file named .nojekyll to the root of the repository there was still a 404 error which confused me for a very long time. It then turned out I needed to make a change to another file to cause the website to be rebuilt, finally correcting the issue.
I still feel as though I am doing many things which could be bad practice, but that is for another day. If someone has any advice relating to that I will award the bounty for it.

Looking at the current state of your gh-pages branch I'm guessing you've mixed the files that were in the publish directory with the source files from your solution? If so, you just need to clean the source files out of the gh-pages branch so only the files you copied from the publish directory are present.
Other than that what you have now looks to be correct.

Related

Getting code from Windows Azure VM

OK, so my hard disk just crashed. Big deal. All my web dev code that was on it went along with it, and now I'm running ddrescue on Ubuntu trying to recover whatever data I can recover. The hard disk keeps disconnecting and sometimes it can quit responding for a long time so it's really a pain in the ass.
Anyway, back to the main topic--I have my web dev code which was packaged and uploaded to Azure; now what I'm wondering is if it's possible to obtain all my .cs files from the VM. I noticed approot and siteroot folders, but all I saw were the views, the .asax file, some other misc, stuff, nothing with the .cs extension.
Is there any way I can get a copy of the code I packaged? or (as a last resort) any way to get the .cspkg file and work from there?
The site you are seeing on the web role and inside the cspkg file is the output of the compile, so you can't get the original .cs files out of them. That said, you can use a tool like Reflector, Just Decompile, or a variety of other decompilers out there to reverse engineer your compiled bits into something that will be very close to the original C# code (not I'm assuming this is your own code, or code that doesn't have a provision against reverse engineering). This at least will let you use the bits on the webrole to get the majority of your code back, then review it to see how good a job it did.
Note, you can open the cspkg file. It's just a zip file. You can rename with a .zip file extension and open it up, but you won't find the .cs files in there. The only time you find this to be the case is if you have multiple websites within a single web role. The default packager for Windows Azure doesn't compile the additional sites, only packages up all the files in their root directory. Not at all helpful for actual deployments really, but this won't likely help you.
You are likely well ahead of me on this, but I'd recommend using a personal source control system of some sort to avoid this issue in the future.

C# view source code of a particular .NET class

I browsed through some questions and this one stood out as the better one:
.Net Classes and their source code which pointed me to this place here: Microsoft Reference Source Server.
I tried everything the site says, downloaded a file that I cannot open from there and at some point ended up with a .pdb file in my source folder for the symbol cache that I could not open with a multitude of tools I looked into.
So this is my last resort to find an answer to my question. Out of pure curiosity (and lack of a better way to understand some stuff) I want to open a particular class from Microsoft (namely I wanna look into RichTextBox and maybe the classes it inherits from) but I simply cannot find a way to make this work for me. I want the original source, not a decompiler product because, well because I mainly need to understand some stuff, not see random variable names. I appreciate any help that may get me around my stupidity and clumsiness, as well as the right tools to do so (if any other than VS).
Note that I am using Visual Studio 2012 and yes, I went over a guide covering this specific version instead of the guide on VS 2008.
The "download" links on this page: http://referencesource.microsoft.com/netframework.aspx should work. However try downloading them via Internet Explorer; my Firefox attempted to download an .aspx file instead of the installer itself for some reason. (EDIT: as #ParagMeshram pointed out, just rename the netframework.aspx to netframework.msi as a quick fix if necessary)
In addition, here's a link to the source hosted by dotnetframework.org: http://www.dotnetframework.org/default.aspx/4#0/4#0/untmp/DEVDIV_TFS/Dev10/Releases/RTMRel/wpf/src/Framework/System/Windows/Controls/RichTextBox#cs/1305600/RichTextBox#cs
I can't say for certain if it's the latest greatest, or what you would be compiling against exactly, but should give you a good idea of how it works.

Published Web files, can they be converted back to solution?

Is it possible to take a set of published web files and convert them back into a solution? I say this because a solution has been lost from our system, and the only files that can be found are the actual published files. I have looked around and can't seem to find anything on the matter, any help would be great!
Thanks a lot
For a Web Application the source code is compiled into DLL's. As far as I know there is no easy way to reverse engineer a Web Application back to source code. If you wish to do further research, use search terms such 'reverse engineer web application DLL', or 'retrieve source code from DLL' etc. Good luck!

How to write and testing ASP.NET 4 on notepad?

Conditions:
I've been asked to develop a simple ASP.NET 4(C#) project in notepad. I'm completely new to this area.
The completed project should include several .aspx files, one master page, one sitemap and a web.config.
The book I'm using is a beginner cook book, based on using Visual Studio 2010 Express.
Developing it on notepad is a requirement to this school assignment.
Questions:
As what I know now VS2010 has its built-in Development Web Server which notepad doesn't. Should I test .aspx files by opening notepad files in browser? Will tags with runat="server" work?
Is there any helpful site or post that you know?
How should I testing master page?
Forgive my noob questions. The most sites I can find is teaching people how to develop by using VS2010, which is like my book, instead of notepad. The schedule is tight so I need some help here. Thank you for your time. I'll also share my experience when I finish this assignment.
It's a little more complicated than "runat="server"".
To give a little bit of 101, you will need:
A web server. The most natural one to use is IIS. I believe you should be able to use Apache as well if you're feeling adventurous.
The application framework. Guess what, it's .NET! There's also Mono if you're not using IIS. The application framework should also include the compiler. C# is a compiled language, so before you can run the code, you will have to compile it first. This is slightly different when compared to PHP.
The editor. You should be able to use Notepad, but Visual Studio provides you with more than just a fancy text editor. It helps you create the build script (the command that you send to the compiler), it helps you with project organization, and it helps you debugging.
So just using Notepad is doable, but you'll lose so much time for not using a free tool like Visual Studio Express.
Now to actually answer your questions:
No, it doesn't work that way. You will need a web server (see point 1 above) and a compiler (see point 2 above).
That's a little bit too broad. Your book should be a good starting point.
See answer 1.
I have finished that assignment. Here is my experience:
First, to develop an ASP.NET project on notepad or textpad is very unwise, unless you want to test your coding skill or having some other reasons. Because for beginner the best way to test your code is using VS "Ctrl+F5". If you write your code in notepad/textpad and test them in VS, it kind of defeat the original purpose.
There is a few tips, for the beginner like me.
Named your sitemap file "web.sitemap", and put it in the root directory of your project, otherwise you may have to go through complicated configuration process.
P.S. This is not a compulsory requirement, you can change the file name or directory, but you need to add site map provider in "web.config".
2 Choose your solution or project root directory carefully, because it is not easy to redefine it.
P.S. I spent a lot of time to move files around in Windows Explorer because I wanted to change my current solution directory to another folder.
These are the tips I find most useful. I would've saved at least 2 hours if I know these in the beginning.

Why is my ASP.NET MVC project saving several copies of itself?

This is really weird behavior, let's say I have an asp.net mvc project as follow on my desktop (vista):
/mvcapplication/app1
then over the course of development, I copy this solution to a briefcase on a thumbdrive so I can work on it from a laptop (xp).
When I insert the thumbdrive back on the desktop, I notice it's taking longer and longer to sync, eventually it took so long that it just hangs there. I checked the project structure and found that it is now:
/mvcapplication/app1/app1/app1/app1
with each /app1 containing the entire project structures. I am not new to visual studio, and I am sure I opened and saved the solution and files just as I normally did, but this is just bizzard. I thought this is caused by briefcase, but the same thing happened when I copied the solution into a folder on the thumbdrive.
I would have left this alone, but with that sort of crazy folder structure it's really difficult to determine which folder has my current changes..
Anyone ever run into something like this?
Never had this happen but then I don't use the Briefcase. Then again, I try to avoid most things in Vista.
I just use good 'ol copy and past for thumb drive stuff.

Categories

Resources