Better approach for my first asp.net project? - c#

Background info: 2 semesters of C#(WinForms), plenty of HTML/CSS skill, brand new to asp.net.
I'm building a site for a friend who's a photographer. It's just a gallery site, but he'd like to be able to update the galleries himself and he's not tech savvy in the least. So I'm using the following approach to the problem:
Using ASP.NET 4 WebForms:
I'm using System.IO to get the names of the folders which represent the "Galleries" and populating a TreeView control for navigation.
When a "Gallery" is selected, I have code that builds a (HTML)list of the image files and populates an UpdatePanel with this list.
As this is all based on the folders/files, I'm building him an secure admin page to upload files to new or existing galleries(folders). He'll also be able to edit(move/delete) the existing files from there.
I got it all to work, which was a nice little victory, but I'm realizing this approach is not optimal, as none of the unique galleries are findable via search engine or even URL; the SEO value is nill; the browser back/forward buttons are useless...
Can you guys/gals recommend a better way to go about this?
Is there a way to modify what I've already done to optimize the project?
I'll gladly start over to do this right.
Thanks

Couple of suggestions, if you are doing this for fun - and want to learn something, consider using ASP.Net MVC instead. Both will work, but doing it with MVC will give you more up-to-date and marketable skills.
Second, unless you really want to write the whole thing from scratch, consider using a package to do most of what you want and then customize it.
Something like this would work quite well: http://www.galleryserverpro.com/ and is open source, free/cheap and well supported.
SInce you are new to asp.net, you can learn a lot by picking thru the open source code and seeing how other people with more experience have already solved the very same issues.

When a "Gallery" is selected, I have
code that builds a (HTML)list of the
image files and populates an
UpdatePanel with this list.
Well, most of your problem is sitting inside this sentence. get rid of the UpdatePanel. When you are making ajax request, you are not able to allow browser history. so SEO, back/forward nav. buttons are always issue with updatepanel.
http://ajaxhistory.com/

Related

C# Web Application Form using Stored Procedure

As a DBA/SQL Server Developer, I'm often asked to produce web pages where users can view the data in the database and edit them, and see the edits they've made straight away (without refreshing the page). I know nothing about ADO.NET or C#, but I would like to be able to give users this very simple functionality. Essentially I'm looking for three things:
to display a table of data in a webpage retrieved from a SQL Server stored procedure
to display a text box in the same webpage where users can input data
to display a button in the webpage that takes the inputted data from the text box, runs it through the stored procedure as a parameter, and refreshes the table.
Ideally I'd like this all to happen without the user having to refresh the webpage.
My questions are: is this kind of thing possible? How difficult is it to achieve? And how do I do it? I don't have the time to learn web development in full. I wouldn't need the vast majority of skills I'd learn even if I did learn it in full. I just really need this basic functionality, to produce ultra simple pages when user requests come in.
If anyone knows of any examples of just this kind of thing, that I can copy, they would be greatly appreciated!
You don't really need to use MVC, WebForms or even C# for that matter. Using one of those would be killing a ant with a rocket launcher.
Look into node.js and pug, using a RESTFUL API to deliver the information you need. I don't believe you will need more than two hours to provide your users with the interface you told us.
Node has a awesome package called express, it sets up everything for you and uses Pug on the starter template.
You can check out a tutorial right here.
Actually it will also take 2 hours doing with Webforms or MVC . I recommend using Entity Framework to make it super simple.
Webforms may be a bit older technology but will be faster to develop this specific page (assuming you only targeting Desktop users). Otherwise MVC is the way to go.
You can Check the tutorial.
https://learn.microsoft.com/en-us/aspnet/mvc/overview/getting-started/introduction/getting-started

language subsite in asp.net

So we have a site that was made quite some time ago. It uses asp 2.0. Currently the site is not multilingual. Since this site was not created with multi langue in mind it contains a lot of images with text on them.
Some time ago a college went ahead to create 3 versions of the site by basically copying the whole site and translating each one. I'm not sure if that's the best way to do it.
I would now like to go ahead and merge those sites. To create something like www.site.com/en/ for English for example.
What would be the best way to achieve this? Can I just take the main site and create for example 2 langue buttons and subfolders containing the translated versions? or is this more complex?
I should note that the site is using a masterpage.
Thanks in advance!
Globalization of an application is huge topic. You could start reading this guide:
https://msdn.microsoft.com/en-us/goglobal/bb688110.aspx
Basically, you have to:
refactor your code to put strings in resource files
refactor your images to use text from resource files and backgrounds (css will help)
Then you have to translate the resource files and put them in the application.
Then you can use the Routes to set the language in the URL using a route like this:
routes.MapPageRoute("PageId", "{language}/MyPage", "~/MyPage.aspx");

How to prevent saving files asp.net mvc 4 application

I 'm currently working on creating a web learning portal using ASP.NET MVC 4, where my clients requirement is that the end user should not be able to save the file. The save restriction is applicable on all video type files, images, pdf, word docs and powerpoint type files.
I understand the following exceptions and the client is good with this:
User can make use of print screen
copy-paste text
I need your guidance how best to accomplish this.
For video, I came across the following link http://www.strathweb.com/2013/01/asynchronously-streaming-video-with-asp-net-web-api/.
Thanks,
Hemant.
I came across this online tool http://www.docspal.com/ but they doesn't seems to provide any API for the developers.
Am I the only one with this requirement :(
It is really hard to stop users from copying documents from the website.
However, just to lower it down, you should be able to disable right click which may at least decrease the number of users that will try to copy your content. Do something like following in jQuery.
$(document).bind('contextmenu', function (e) {
e.preventDefault();
alert('Right Click is not allowed');
});
Refer to this for more.

Search engine optimization for database loaded using jQuery

I am currently optimizing my site for search engines. It is mainly a database driven site. I am using C# on the back end but database content is loaded via jQuery ajax and a web service. Therefore, my database content is not in html at the point that the bots will crawl it. My site is kind of like an online supermarket format in that there are thousands of items in my database, users can load a single one of these or more onto the web page at a time and the page does not change significantly once items are loaded.
My question is, how (if at all) can I get my database contents indexed? I was thinking of having an anchor that links to an aspx page (eg called mydatabase) which loads all of my database items as a big html list. Then, using jQuery, I would make the anchor invisible to users. The data would still be accessible to users but not by this link, it would be accessed by using the jQuery interface I have created.
The thing is, I don't really want users to see this big, messy list - would google results show this page eg www.mysite.com/mydatabase.aspx as a search result? Also would google see this as "keyword rich" spam page? I have done quite a lot of research but found nothing on this. only instructions for php. Please help I'm not sure what to do and need to know the best way to go about this.
It's a shame you haven't taken the progressive enhancement approach as it would mean you would have started with a standard HTML output that's crawlable, and then adding the layering behaviour (AJAX) on top for the user experience.
Providing a single file (e.g. mydatabase.aspx) that lists all of your products in a list format provides no real value for the reason you gave - it would just be a big useless list. No editorial content relevance for each link etc.
You're much better off taking another look at your information architecture and trying ensure that each product is accessibile by it's own unique URL, then classifying the products into groups (result pages), being careful to think about pagination.
You can still make this act like a single-page application using AJAX, but you'd want to look into HTML5's History API to achieve this in a search engine friendly way.

Yet another .net custom cms

I'm trying to switch my custom cms written in php into .net c#. I was thinking to use cms as a learning project. I'm going to use C#, NHibernate ORM layer, mssql, mvc3 and jquery.
I'm aware there are plenty of commercials or open source cms, but still I'm going to spend some of my free time trying to learn new technology working on project like this.
So, is there anyone out there who is willing to share some ideas on creating cms domain model, usefull link, ideas, etc.
Thanks
A really basic CMS consist of 3 elements:
one database table to hold your "pages". The table structure is "name" and "content"
a route to transform requests of type /cms/pagename to a fixed controller, the method called cms and pagename as a parameter
a embeddable html editor
Now, there are two ways your "page" can be invoked. It is either create mode or view/edit mode.
In "create" mode, the page is requested but it is not in the database yet (e.g. cms/announcement1). In this mode you create a view consisting of a html editor and upon submit, you persist the page to the database.
In "view" mode, the page is requested and is IS in the database. You perform any necessary rewriting (for example you rewrite internal links of the form [cms/pagename] to a fully routable http address) and render the content.
If the user is authorized to edit the page, you also show a "edit" button which then invokes the html editor with the page loaded and ready to be edited.
And that's it.
There are tons of additional elements (caching, different built-in page types, embedding images, youtubes, preformatted texts) etc. but all of them are optional and you can introduce new features when you have the core already implemented.
Once I wrote a simple CMS following the structure above, it was a part of a bigger solution and till now it's been sucesfully deployed several hundred times. An advantage of a custom CMS is that it can be really simple and easily maintanable.

Categories