How to find and remove unused .aspx files in Website project - asp.net

Recently I've been working on a big ASP.NET Web Forms site and it has some pages that apparently are not in use anymore, but no one knows for sure (this is an inherited project). Is there a way to know if those .aspx files/pages are being used or referenced?
This is not a Web Application Project but a Web Site Project; so I guess it's more difficult to find what .aspx pages are being used and which ones are not. if anyone has experienced something like this, what was your approach to clean this up?

No, probably not. What would be the criteria for that, if no one knows for sure? If you developers can't tell, how would some automatic system decide this for you? You don't need to have .aspx referenced in code for them to be used.
You can use search function in VS to find references inside the project, but in a big website like yours it might be kinda slow and problematic. I'm afraid you'll have to go page by page and figure it out by yourself.

Related

Code-blocks are not allowed in this file - Where is My web.confi file

I have a sharepoint at my office. Its 2013 version. Where I want to write some asp code. But the issue is SharePoint is blocking the code and I am getting error "Code blocks are not allowed in this file". I searched google and found several links to solve the issue by saying make some changes to the webconfig file.
Now my question is how do I find the file. Where it is actually.
What I have is a sharepoint, I don't have any designer. I only have admin access for this site. Can some one please guide me.
I know there are several entries here in stackoverflow, but no one is talking about where to find the file.
Please help me.
My apologies if this happens to be a repetition, in that case please point me to the right post. Thank you guys.
By default injecting server-side code (ASP.NET) in SharePoint pages directly from sites is not allowed for performance reasons, and should remain as is.
If you never approched SP developpment and are not an administrator of the farm in your company I strongly advise you to see first if you can solve your needs with client side development (javascript) instead of going to server side (ASP.NET).
SPS2013 comes with the "Script Editor WebPart" that you can use to inject your custom JS on pages. If you need your custom on all pages consider adding your JS on the site's masterpage.
From JS you can use SharePoint REST API to interact with your site https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service
If you need heavy customisation for your site you can move to the addin model (client side) that will require Visual Studio IDE develoment suite.
And last option is if you explicitly require serve side code and/or need to develop a scalable enterprise grade solution, you will need to make a "SharePoint full trust solution package".
PS: You may see articles around about "SharePoint Framework" (aka SPFx), unfortunatly this is not available for SPS2013.

Why do I need a web.config in all view folders in MVC?

Trying to find a solution I read this question: What does the Web.Config file do in the views folder of a MVC project
But I still want to know: Why do I need a web.config in all view folders in MVC?
This answer The web.config file exists in the Views folders to prevent access to your views by any means other than your controller is not enough for me, if it's true, it's a temporary solution.
If this is really the only reason, this is a huge point to improve. But, I'm pretty sure there is a good reason for that.
Ahh, yes, I agree. In another answer in the same thread this reason is given:
This file also contains configuration needed to make the standard
ASP.NET ASPX page compiler work properly with ASP.NET MVC view
template syntax.
So I infer there are some backward compatibility issues that may need to be worked out.
But I do agree with your central point that this is something that should be improved upon in future iterations.

Can someone give me an overview of ASP.net and how it's different from technologies such as php?

I've been doing the html and css for a site, sending it off to a guy to implement in a web server. I get a call from the designer freaking out about the progress, saying the clients aren't happy. He wants me to personally integrate my css with what's on the site. The site is done in ASP.net, time is short, and I'm a little in over my head. I have an understanding of how php works, but have never worked extensively with it.
Looking at the stuff on the ftp, I can't even find equivalent of the index.html file (I know that when I go to the site itself, there is nothing after the base url, i.e., www.site.com/ brings me to the homepage.)
Can anyone give me a few tips or links as to what I am to do with this, or where to even being navigating this site?
EDIT: It's -not- a .Net Web Application, from the looks of it.
ASP.Net can be run in a compiled or a scripted environment. It is important to understand which environment your client has. If it is completely scripted, then you are likely looking for the default.aspx file and it's contents. If it is a compiled environment, you may be in for a ride. A compiled site may incorporate "master pages" as a templating engine, and then you'll need to apply your html/css modifications in several places.
You should start with the default.aspx page if there is one. Look for master page directives (it'll be named something like masterpage.master). If there isn't one, then you're in luck you'll just need to implement your changes on a page by page basis. The aspx page will be in a templated xml format so avoid touching tags that involve touching
If you are making changes to divs and structures of that nature, you may need to modify the CssClass attribute of the controls. I would recommend however that you make a back up, give it a shot, and under no circumstances attempt to do something that you aren't really ready to do. You will only anger the client and ruin your rep. It may actually be prudent to contact an actual ASP.Net developer to analyze the files separately and determine what you need to do.
I suggest that you read the Wikipedia article about ASP.NET to get familiarized with it as it summarizes the basic building structures.
Then, just to get you started: take a look at the more recent ASP.NET MVC (Model-View-Controller) paradigm. There's also development in what is called ASP.NET WebForms.
For example: when you go to www.site.com/ (known as friendly URLs) it may be redirecting you to an action method inside a controller. It's called routing. There's also URL rewrite.
In the MVC world a Controller can send/redirect the user to a specific View/Page.
A View (.aspx form/page) that contais HTML markup and CSS on the server side is basically an HTML page (.htm) page that'll be rendered on the client side.

ASP.Net website makes browser load unwanted (non-referenced) plugins

I've found that some of my ASP.Net web apps prompt the browser to load plugins that I'm not explicitely using and certainly haven't deliberately referenced in the project settings.
Two that come to mind are for MS MediaPlayer and the "SVG Viewer for Netscape".
The only commonality I've determined so far is that the two sites/apps affected both use Master pages (nested in some cases).
We don't use SVG file types (just the normal mix of jpg/gif/png) and no video/audio (not yet anyway).
Can anyone provide a hint as to where the references for these might be creeping in? e.g. Is it a server-level include? Or a .Net runtime default when using master pages?
Does anyone else even experience this, or is it just me?
No urgency, I'd just like to remove it if possible.
Thanks.
Al
If you look at the page source in your browser, you should see what's in the page that requires a plugin. If you load external Javascript, you will have to look at that too. Do you have ads on the site that include 3rd party code?

asp.net help resource location

I have a relatively simple site that I'm working up for an intranet environment. The pages have a hook to display a simple bit of text (possibly with a bit of HTML for markup purposes) for help when the user clicks a link on the page. I'm debating whether to put the help snippets in their own XML file or create a section in web.config. The site is to be deployed across several client sites and given that updating a web.config file appears to restart the site, I'm leaning toward having it in its own file. My question is where would be the best place to locate it? I'd rather it weren't easily web-accessible, so although root or some folder is an option, I'm wondering if there is a more "standard" location for files like this, App_LocalResources perhaps? Any feedback would be welcome. Thanks.
I will look at these options. I don't anticipate a lot of updates to the help file/resource, but I think as the function of the site expands, it's certainly possible. I like the idea of it being something like XML or at least editable in a text editor so that updating doesn't necessarily require VS to update the file. Thanks all!
Sounds like a perfect candidate for resx (resource) files in the App_GlobalResources folder. Those are easily editable and posted to a site without any restarts.
What about using an embedded resource? There are several tutorials around how to use embedded resources and package it up in a dll to distribute along with your website.
In my projects, I connect the web application to an online help wiki wherever possible.
The .aspx page name is used as the help page title. Once you are in the wiki, you are free to do all the wiki tricks, such as redirecting and linking
See my blog entry for technical infos.

Resources