I am building a website with asp.net. But I have an issue: I want to make user profile page link like in facebook.
For example,
"hostname.com/username" instead of "hostname.com/profile.aspx?something=something"
How can I achieve this?
Thank you for your time and valuable answers.
That feature called "URL Routing". If you are using MVC, then MVC Framework has That feature included. But if you are using Web Forms application, then You have to do this manual.
For Web Forms application, You can use Nuget Package Microsoft.AspNet.FriendlyUrls to make your application so that it generate url's what you want.
Refer http://www.devcurry.com/2013/05/friendly-urls-in-aspnet-web-forms.html
http://www.hanselman.com/blog/IntroducingASPNETFriendlyUrlsCleanerURLsEasierRoutingAndMobileViewsForASPNETWebForms.aspx (This is microsoft suggested)
This is typically done with a framework of some kind, but the concept it fairly simple --
If you're trying to do this quickly, you'll want to do your research on which one to use, but I'll explain the principle that makes it work -
In your server config (like an .htaccess) - you will rewrite the requests for *.aspx files go to a central index.aspx - this file then bootstraps your index however you want -
In your case, it would take the /username portion and query the database for a user with that username, fetch the associated data, and do whatever with it.
It's a relatively simple concept, and you could write something of your own device to bootstrap the request to your code, but you're probably better off looking for some (micro)framework that handles all that for you...
Good luck - !
Related
Language: C#
Skill: Beginner
Tool: Visual Studio 2010
Technology: ASP.NET 4.0 WebForms
Hello StackOverflow,
I intend to develop an asp.net web app for my final year project (to complete my bachelors degree) ,Scenario is that I want to allow users of the app to post videos(vidz) and these vidz can only be watched by the user who is allowed by the owner of the vidz ,further more the viewer should only be able to view the vidoes...
I came to know about the DRM solution of silverlight but i think its comes with some cost ,so for me its unaffordable..
it's a bit of a kludge but I used the approach below to protect images from being downloaded without the right cookie being set ... a variation could be used to hide the video from random attempts.
if you need to be really certain that it's protected then a solution like PlayReady is going to be the answer, but if you just need to avoid casual "fly-by" then this might be enough
http://blog.offbeatmammal.com/post/2006/06/30/Using-ASPNET-to-restrict-access-to-images.aspx
If you're using ASP.Net MVC I recommend you to take a look at this project:
http://mvcresumingactions.codeplex.com/
By adding authorization layer on top of your controller you can easily manage access to that controller based on your own logic (Like members who have access to that video). For more information about authorization you can take a look at:
http://nerddinnerbook.s3.amazonaws.com/Part9.htm
I know this is little bit generic but I hope this can give you some clue :-)
I'm looking for best practices and good ideas rather than a proper solution.
scenario: I work in a web agency and thus we are plenty of websites from several customers. They're built upon a cms we made, so websites are quite identical for the 90% of code. However, remaining 10% struggles me and my team as it involves not only the presentation layer but behavioral logics too (ex: a website1 requires simply user/pass registration while website2 needs more data, facebook connector, etc. But this is a very easy example).
Making ad hoc development for our customers is becoming painful as keep each version aligned is getting really hard for us
What I really dream to have is an extendible website that works by itself, but in which I can override a part. This behavior should sound like "look for the specific part, if it doesn't exists get the base one". The parts could be a method, a class, a page, a control, a static file.
example:
Suppose I want website2 to have an own login component, let's so imagine that we have a situation like:
/website_base
|_ login.aspx
/website1
/website2
|_ login.aspx
So, if I ask for www.website1.com I'll get /website_base/login.aspx, but if I ask for www.website2.com I'll get /website2/login.aspx
Any idea?
Thanks
PS: we work with asp.net 3.5 framework.
There are couple of ways to achieve this.
Approach 1:
1. Split the common functionality in modules and create a pluggable structure. (like DotNetNuke) Obviously this will be more time consuming initially but over the period of time it can make itself like a product.
Approach 2:
Firstly - I would create separate solution for each client for better maintainability. This will save me a lot of hassle while maintaining the source control and when one client comes back with issues and we have multiple releases for a single client.
Secondly - From my core solution, I will identify most commonly used artifacts for each layers and move them to a core assembly.
a. For example – In UI you can use themes to give different looks for each client. Have a default master page which comes with the core site structure. All client specific details like Logo, name, contact details etc… can be configured using some DB fields.
b. In Business Layer and Data Access Layer – core functionalities like Membership, Logging, CMS related Entities etc I would have as a dll
i. I will derive my client specific logic from these core classes.
Last but not the least – how you deploy your code and how your IIS VD structure looks like… I believe it will be totally dependent on how the solution is packaged.. I would create a deployment package for each client which will give them the ability to deploy it to any server wherever they want until you have specific issues about proprietary software hosting.
Look into ASP.NET MVC. It is much more extensible than Web Forms, can be integrated into your existing Web Forms application, and it is very easy to build reusable custom components like what you are describing.
Otherwise, I would suggest looking into WebParts and developing reusable custom server controls for the components that you need. This way you can encapsulate the complex functionality within a single UI control without having to write repetitive code. WebParts are also compatible with Personalization, which you can leverage to manage the variance between which sites use which controls.
I definitely recommend MVC as the way to go for building extensible .NET web applications, but learning a new technology always incurs a cost in the time it takes to understand the new paradigm. I hope this helps you.
I found a smart solution here: http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx
Check it out
I'm not sure I'm asking the right question here, but I'm looking to provide web based functionality from one ASP.NET application to another remote 'portal-like' application. Is it possible to simply give the portal a DLL? As an example, let's say the SaaS web app has a patient-entry form that I want to be able to use from the portal application. I would like the portal app to be able to set preferences (permissions, color, style, etc), make a function call, and have that capability presented within a certain div or something. Is there any .NET technologies that provide this kind of integration?
EDIT:
Here is a link to a quick diagram I made trying to describe the scenario: http://img.ly/ESG. I know there are other ways of doing this (eg JSON-P calls), but I need to give the portal developers something they can control on their end. Also, if anything changes they'll know I will send them a new version of the DLL which will indicate to them the new functionality.
I'll give you a shopping list of things to check out:
DotNetNuke:
http://www.dotnetnuke.com/
Workflow Foundation -
http://msdn.microsoft.com/en-us/netframework/aa663328.aspx
Microsoft SAAS platform -
http://www.microsoft.com/serviceproviders/saas/default.mspx
Depending on exactly what you're looking for, you might also research "multitenancy".
To answer your original question, yes, you can do it with DLL's, but there are easier ways to do it.
Background:
I am an intermediate web app developer working on the .Net Platform. Most of my work has been defined pretty well for me by my peers or superiors and I have no problem following instructions and getting the job done.
The task at hand:
I was recently asked by an old friend to redo his web app from scratch. His app is extremely antiquated and he is getting overwhelmed by it breaking all the time. The app in question is an inventory / CRM application and currently each customer requires a new install of the app (usually accomplished by deploying it on a different domain on the same server and pointing to a new database).
Currently if any client wants any modifications to the forms such as additional fields, new features, etc my friend goes in and manually adds those fields to the forms, scripts, database etc. As a result all installs of this application are unique. There is no one singular source repository and no one single version of this app. Generally new features are overtime rolled into the other sites, but still this is done on an individual site by site basis.
I will be approaching this on a very modular basis. Initially I will be coding a module that will query an external web service for some data, display and store it, and periodically update it automatically. The next module will likely be for storing and displaying inventory data. This way I want to over time duplicate the current feature set of his app 100% but do it incrementally.
The Million Dollar Questions
I want to make the app have user
configurable form fields. The user
should be able to go to an admin
page, create a new forms page of a
certain category, and then specify
what fields he wants in there. He
could say 'create a new text field
called Item # and make it a
requirement" and that will get
stored somewhere. All forms will be
dynamically rendered to screen based
on what the user has configured. Is
this a good way to go about the
problem of having no idea what a
customer could want in a form? and
thus be able to store and display
form data of any sort ? What sort of
design pattern should I follow here?
I am familiar with asp.net and
the .net framework in general and
have decent knowledge of javascript,
html, silverlight, jquery, c# etc
etc. I can work my way around web
apps in a good way, but I am not
sure what sort of framework or tech
I should use to accomplish this
task. Would ASP.net 3.5 webforms be
the way to go? or should I look into
ASP.NET MVC? Do I use jquery and ajax for
complete decoupling of frontend and
backend ? or will a normal asp.net
page with some spattering of ajax
thrown in working with a codebehind
be the order of the day?
Just looking for general advice before I start.
I am currently thinking of using ASP.NET 3.5 webforms, jquery for clientside animation, ui, manipulation and data validation, and sqlserver + a .net or wcf webservice for backend.
Your advice is much appreciated as always.
I've recently implemented a white-label ecommerce system for an insurance company that allowed each partner to choose their own set of input fields, screens, and order the flow of the application to suit their individual needs.
Although it wasn't rocket science, it added complexity and increased development time.
Consider the user configuration aspect very carefully In hindsight both my client and their clients in turn, would have been happy with a more rigid system.
As for the tech side of your question, I developed my project in VS2005, using asp.net webforms and webservices with a SQLserver back end, so the stack that you're looking at is definitely capable of delivering a working product. ASP.net MVC will almost certainly help as far as testability goes.
The biggest thing I would change now if I was going to start again would be to replace the intermediate webservices with message based services using nServiceBus, MassTransit or the like. While the webservices worked fine, message based communication should be quicker and more reliable.
Finally, before you start to code, make sure that you understand the current system's functionality inside and out. If the new system doesn't do something that the old system did, it will be pretty obvious to the end users straight away.
I have a ASP.Net web application that I want to use as a reusable user control library in other web applications.
One solution for this problem is to use what Scott Guthrie has described here:
http://weblogs.asp.net/scottgu/archive/2005/08/28/423888.aspx
that is to copy ascx/aspx files (without their code-behind) in the web applications which use the control library.
I actually see another solution: to embed the ascx/aspx in the User control library and then use a custom virtual path provider to get them.
Does anybody know which solution is the best ?
From the deployment point-of-view, the virtual path provider seems to be better.
However the 'ascx/aspx copy' solution is easier to implement (no need to create a custom virtual path provider).
I really do not like Scott's solution. I believe it is ungly and creates overhead that is not necessary. I have also seen something similar in action and it just didn't work for me.
I too had the same requirement as you describe and I used the virtual path provider option. This way I could reuse all my user controls between web applications easily and without work arounds.
The virtual path provider has a couple of issues though:
If your ascx file has any server tags (in javascript or any other place for that matter) that cause an issue you will get a run time error that is not that helpful.
You have to rebuild your application every time you do a change to the ascx's mark up or to Javascript that exists on the file it self in order to see the results. That can be a real pain if you are trying to change the design of an existing control.
I have used the solution as described in this article and it worked very well:
http://www.codeproject.com/KB/user-controls/EmbeddedUserControl.aspx
I hope that helps...
I ran into this same situation a few weeks ago and I could not make Scott's solution work. I instead used Custom Server Controls and put those in their own Class Library.
I really don't think its a good idea to use user controls that way. If you need them in a separate library, you should convert them to server controls.