html content/file displayed from browser not existent in webserver directory - c#

i got assigned to a project regarding webdevelopment, which i have very little experience in and am currently trying to understand the structure of the webpage. Right now I can't understand where some of the html code/files are located on the webservers directory. Looking into it from the browser and using webdeveloper tools on a certain page I can see that its named "register.cs" and placed in a certain folder. Looking into the webservers directory I can't find anything related to it not even by searching the whole folder. Does someone understand? The website was apparently coded in C# using blazor ยด.

Related

.Net Core Razor Pages - Server Side Include

I'm unable to get server side includes (*.html files) working in a .net core razor pages web application. I've made sure to have the appropriate handler in my applicationhost.config, but I'm thinking there's a different issue here. Any help is appreciated.
Why am I doing this? I have multiple web applications sharing the server side include files (for navigation bar, footer, head content, etc..). Each of these different applications may be of different Microsoft web architecture. Our goal is to move everything to .net core, but we have lingering web forms projects to deal with along the way.
I have performed a work around by taking the SSI file contents and using #Html.Raw to serve up the content. This is probably wrong also.
I went ahead and changed the file extension of the html files into cshtml which allowed me to treat these files as partial views. I'm using a prebuild event to copy these files from a shared solution folder into my project Pages/Shared/ssi folder. I also copy those partials into wwwroot/ssi for the other applications to use via SSI. Eventually all of the apps will use the partial views instead.
The problem with this solution is that it is not necessarily clear that all edits need to happen in the shared solution folder instead of directly in the project, but the documentation for the project will address this. I tried using linked files, but only one link to a specific file can be made in a project.
Not a perfect solution (to the problem), but this not a perfect website either.

Cannot load photo locally in ASP.NET MVC

So, i am creating an ASP.NET(MVC5) application, on which i want to show an image using an img tag like that:
<img src='#Url.Content(Path.Combine(Server.MapPath("~/Products-Data"), product.Name, product.ThumbnailImage))' />
The problem is that no browser actually load the image. The fun thing is that the link generated by the razor engine is valid, and i can see the image if i open it from another browser tab. After some searching i noticed that in the chrome console, there was this error:
I found a lot of topics regarding this error(change settings in web.config, use the --allow-file-access-from-files flag and e.t.c), but none of these actually worked. This is going to be a real-world application ... but for the time being i need to test it locally, and check if everything works properly. Any work around's here folks ?
You just need to generate the path using relative path, resolving it to the absolute path wouldn't work, as it will be the path of the server's particular drive location which is most of the times outside of the working directory of the web application and it is not possible for the browser to fetch the resource using physical path, so it wouldn't work for you.
You would need to do do it something like :
<img src="#Url.Content(String.Format("~/Products-Data/{0}/{1}", product.Name, product.ThumbnailImage))" />
and it would be more better if you pass it via Model object the relative path and the view just have displaying code, view should not contain logic to generate the path.
Hope it helps you!

Using the right search method in windows 8 app

I'm creating a Windows 8 app that can upload content from the local machine into the app (for local storage). I need to search through this content. What is the preferred strategy to use to incorporate this search functionality?
I have been trying to use the SampleData.json and SampleDataSource.cs from the grid template app as a starting point, but to me, it seems like the SampleData.json file will need to be updated each time new content is added to the app, seeing that data is populated from the SampleData.json file.
I have been going through the tutorial from MSDN:
Is there any other tutorials or advice anyone has for me? I need to incorporate this asap
Windows can index files for you, and then you can use the StorageFolder.CreateFileQuery[WithOptions] APIs to search via properties. If you place content inside a folder called "Indexed" in local or roaming app data, then indexing happens automatically and queries execute very quickly. You can also store the content in "appcontent-ms" files if that works better.
There's also the [Windows.Storage.Search.ContentIndexer][2] API for nonfile content or content that can't live in Indexed appdata folders. The ContentIndexer has its own query methods.
For all the details, see the section "Indexing and Searching Content" in Chapter 15 of my free ebook, Programming Windows Store Apps with HTML, CSS, and JavaScript, 2nd Edition. Even though it's using JS as the language, much of the book is just about WinRT so it's entirely useful even if you're working with C#. And it's free, so there's nothing to lose!

Any solution to use non-guessable links in a program?

I've been looking for a file hosting site to host my files and my friend offered me a premium account on Box.net.
The problem in this host site (and on many others) is that the links arent guessable, they cant be predicted. That means: If you upload 2 images called "1.jpg" and "2.jpg", the links aren't like
"www.host.com/omar/1.jpg , www.host.com/omar/2.jpg" ,
instead, they are like
"www.host.com/qweqwasd , www.host.com/123lqqwje" ..
So I cant use them on my application since I upload a lot of small site and I cant copy each link manually, it will take days.
Is there a way to override this problem in a program? maybe run a script to get all the links on the site?
When you upload a file, presumably the page shown afterwards gives the link - so just parse that page and extract the link from it.
Just think about how you'd get the link if you were a human, and do the same thing in code. (I assume you're already performing the upload in code.)
Alternatively, use a different file hosting site, which lets you specify the filename.

Home/Landing screen design for a website in asp.net

I have an web based application. The content for the Home page has been currently mentioned in the HTML code for the Home page using , and tags. To change the content anytime in future, it needs to be changed in the HTML code. :(
Is there a way that we can pick up the content from some external place and get it reflected through the website. This ways, any change if required can be made at the external location without referring to the application's code.
Please advise if there is any solution for it.
Thanks.
You can
Use a database
Include external files using Server Side Includes
Read external files and write their contents and an alternative method
Sounds like you're looking for a Content Management System (CMS), which will allow your content editors access to modify only specific blocks of a page that you specify.
There are a ton out there to do what you want, so you don't have to start from scratch. Just Google 'CMS'.
Although I haven't used it myself, DotNetNuke is a popular one these days and has a free version.

Categories

Resources