Hopefully a simple question:
When creating a typical asp.net webforms app, the "real" home page url will be something like "https://example.com/myapp/index.aspx".
Of course, this looks like garbage in the user's web browser. Is there a simple way to have it appear as just "https://example.com"?
Is the solution a routing rule of some sort?
Thanks for any help,
-Pete
Well, you only see/have/get a sub folder, since that is where you sent/published the web site to.
So, if you publish to the root of the web site, then in theory, yes, you should be able to just type in the "base" URL of the site. In some cases, due to a "default" page setting, then when you type in:
www.zoo.com
It "might" say default to:
www.zoom.com/Default.aspx
now, of course we "often" setup what are called friendly URL's, and thus this will keep (hide) the aspx extension.
But, there should not be the sub folder you have, and that suggests/means that you published to a sub folder of your web site.
Related
I've been using Index.aspx as the 'home' file of my web applications directories for the past 5 years, but have only just recently started using Visual Studio for debugging sites.
The built in web server for Visual Studio has Default.aspx as the 'home' file.
When I click on a link such as /News?id=5, its not picking up on the Index.aspx file, and instead showing a directory listing.
This causes an issue because I'm sometimes passing querystring, which is then lost when going to the directory listing.
Therefore, should I cave in and do what Microsoft tells me, and use Default.aspx?
Is this what all other ASP.NET web developers do?
I think you can set this up in the web.config file.
[CORRECTION]: What I was thinking of is actually the section, which allows to setup 404 pages. You may use that to redirect to Index, but it might not be "good practice".
Hah, amazingly enough, somebody already asked almost the same question, and even another closely related one, that you probably may use to solve your issue.
You can also write an XML SiteMap file to setup Index.aspx as your toplevel page.
As per convention, as stated in my comment, ASPX.NET convention is to name the pages by the name of their controller's action method, such as Index.aspx, however all examples in the MS70-515 book are based on Default.aspx. My personal opinion therefore would be to use Default.aspx.
I am trying to use aspx pages as an email templates. There will likely be a bunch of objects on the page which will be used as replacements in the html. Because it's an aspx page I'll be able to use databinding, repeaters, etc. At run time, I want to be able to instantiate the aspx page from its path, pass in a bunch of properties, and then get the rendered result of the page and email it. This seems pretty straightforward from a asp.net website (maybe using BuildManager or Server.Execute.) However, I want to be able to use the same templates via a console application by just loading up a page object from its filepath. Is this possible?
You could host your own webserver. Like the Cassini webserver.
In my own application (a Windows-based Desktop-CMS), I include a web server, too (non-Cassini). It works very well, also it does not serve ASP.NET but plain, HTML.
As I did some research back then, I first wanted to use the Cassini, too, but at some point, I found out that too much user privileges were required to run it successfully; this may not be an issue to you, but keeping this in mind and try to run it early with the permissions of the later user, might be a good idea.
We recently rewrote our company homepage and have come across a peculiar error. We have very few pages that need any code behind them, so we wrote the website in static HTML served out of IIS6. The few pages that need any code (Contact Us, with a contact form, for instance) are .ASPX pages.
The previous version of the website had more .ASPX pages, even if there was no code in the code-behind. One of those pages was "management.aspx", and in the new site this is, logically enough, "management.htm". We're smart enough to not just change the file extension -- we rewrote everything, it just has the name in common.
Here's the peculiar part: Even though every link in the entire website points to "management.htm", IIS6 continues to try and serve "manangement.aspx". I've reset IIS, stopped/started the Default Web Site under IIS6, deleted pages from "Temporary ASP.NET Files" and deleted out temporary GZIP files from the server as well. This isn't MVC or anything, so we have no explicit URL routing, and while I can see us having to implement static file handling in our web.config httpHandlers, I can't imaging that being a necessity.
What gives? Why is IIS6 still trying to serve the old "management.aspx" page when we're explicitly asking for "management.htm"? What can I do to fix it?
Your bindings have to be off somewhere... check top level for *, *.htm, managment.htm, etc. Then check virtual directories.
If you paste "http://yoursite/management.htm" in your browser and you get a YSOD, this is an IIS issue for sure.
Check if you still have the bin folder in the root of your site.
Do you get a 404 because it tries to load management.aspx and it's not there?
Check the Default Page on the Website/Virtual directory in Question, and if it exists remove the reference to manangement.aspx.
This is the scenario:
-Hosted web application.
-Application trust level is full trust, because of external components.
-Customer should be able to customize some web pages.
I thought about using an html template that they can modify. But it is not flexible enough.
For example if there is logic things get messy and difficult: if user is logged in render this way, if we are in that page render this part differently, etc, etc. I end up creating a new scripting language, customers won’t like it.
I would like to use an aspx page that they can modify. The problem is that they can write any code in the aspx page, access the file system, etc.
Questions:
-Is there a way in ASP.NET to restrict certain directory or web page permissions (i.e. code access security per page or per directory)?
-Any other suggestions for implementing secure customizable web pages?
Do not do this.
No matter what you do, there will be security issues. Give them a template only, and you process that yourself. As far as I'm concerned, a wiki markup like Markdown is quite acceptable.
Mentioned stackoverflow only as an example, but if you look above the URL for ask is
http://stackoverflow.com/questions/ask
which means /ask is a subdirectory, but they also do this for the specific question pages. How do you code this in .NET?
Not a code question as much as a technique. I know this is great for SEO, but how do you create a site so that every "page" is its own directory? Dynamically.
Do you have a template or a hidden redirect???
How?? :)
It's termed URL rewriting:
Url Rewriting with ASP.NET
MSDN: URL Rewriting in ASP.NET
EDIT: As #Justice points out, StackOverflow uses Routing.
StackOverflow uses something called Routing, which comes with .NET 3.5 SP1. Routing is a popular feature of a number of MVC frameworks, such as ASP.NET MVC, Ruby on Rails, and a number of Python and PHP frameworks.
Stack Overflow was built using ASP.NET MVC which uses a technique called Routing, see:
What Was Stack Overflow Built With?
and Routing
Stack Overflow uses ASP.net MVC
MVC uses the URL + Query String to determine the content, so its not like a URL which points to a specific page, but more like a hierarchical path to the properties of some data to be displayed
E.G. https://stackoverflow.com/users/[Put User ID Here]/[Put User Name Here]
prompts the website to display a USER with an ID specified in the path ( in this case the user name is probably just for kicks ) as opposed to a specific page created just for that user.
I have seen this accomplished by simply creating a folder for every web page and then having each folder contain a Default.aspx document (Assuming Default.aspx is setup as a default document in IIS, which it is by default). Then you can navigate to any folder on the site without specifying the page (Default.aspx).
For the dynamic part, I have worked with CMS systems that do it this way and the Default.aspx page simply inherits from some master template and the CMS system utilizes the ASP.NET rendering enginge to dynamically complete the web page.
Using folders may be a little heavy with the site structure, but it is an easy way to eliminate the page names from the browser.
This is how I structure my website and avoid having to use page names... for example http://www.innovaapps.net/Blog simply brings up the default.aspx page without having to specify the page name.