How do I create a web crawler in ASP.NET? - asp.net

I am wondering if there is a way to make a web bot/crawler for a website in ASP.NET.
I have to grab information from one of our payment providers, but they do not have an API so the only current way to grab the information automatically would be to log in to their page and then fill out a form and retrieve the information.
Is there any way to do this?

you can do this with the webclient() in .net but I wouldn't do it from a web page. Make it a service you can call and get data from.

Related

How to access and edit HTML from a website without any webservice and webapi

I want to access and post the data to a website .
The Problem is i can't use ant webapi and webservice.
The requirement is to add the timesheet details of the employee to the employee's portal website. We don't have any web api or web service for that.
Someone advised me to check the web scrapers.
I googled the web scraping and but didn't find the adding data to website.
Can someone please suggest .
I think your best bet would be to open up your chrome developer tools, submit the timesheet details and investigate the call that was made to the employee's portal backend.
Then you can write your own backend and reproduce that call (using HttpClient or RestSharp).
Don't forget to investigate the authentication as well, as you'll probably gonna have to send a security token together with your request.

ASP.NET ADFS authentication to access sharepoint

I want to build an application to access sharepoint website. First I have created a login form..
I want to authenticate via ADFS How to do that from my website.
How to access the sharepoint utilities after logged in.
That's it. I just want to show the files/documents at my website.
Please share me links or sample if any one have. If available in MVC then no problem.
Thanks in advance.
As you want to display SharePoint List/Library data in your own application/website, so in this scenario, there are two approaches:
Approach 1
Use RSS feeds to embed SharePoint Data into your Application/Website. You can use any RSS Feed viewer for your application.
Approach 2
You can use SharePoint Client Object Model (CSOM). Using CSOM you can get data from SharePoint Environment and use the data to embed in your application.
Here is a reference link to get familiar with CSOM :
https://msdn.microsoft.com/en-us/library/office/fp179912.aspx
Hope these details will help you.

Inserting into database from many different websites

I have a customer enquiry management website with many different websites (on different servers) sending enquiries into it. Currently each website has a contact form on the page and the form creates a database connection with the SQL needed to insert into one central database.
This works but the problem is more and more websites are now sending in enquiries so I am duplicating this database code across many websites. If I needed to change something in the database, I would need to go through all websites and make the same update.
The enquiry management website is asp.net. The websites which insert enquiries into the database are a mixture of asp.net and php. I thought about just creating an insert page on the main website and each website posting to the that. The only problem with this is each website has its own website specific tasks to as well e.g. sending emails, adding to mail list. Inserting into the enquiry database is the only task which could be done externally/globally.
Is there a cleaner way of doing this?
To centralized your all the logic, you can implement Web Services. All you have to do is,just make a web service having all the business logic.
Then you can use this web service by adding the reference of it into your multiple web sites. It will be a one time job. Suppose,if you need to change some logic,then you can just change it in web service class. All the modifications will be applied to all websites which are consuming the same web service.
I think you can expose the operation through web service. if you are in .net platform, web api is a good way to implement that.
You can issue an ajax call to the web api on all the clients regardless the website platform (asp.net php...). If the form is in a similar/standard format, the javascript block can be centralize as well.

How can I use an ASP.NET MembershipProvider to carry over users' session data stored in cookies set by ColdFusion?

I'm working on adding a new webapp to an existing website. I've been directed to write the webapp in ASP.NET. The existing website is written in ColdFusion. For the most part, the ASP.NET webapp is completely stand-alone, but it needs to interact with the ColdFusion code in one important way - if somebody logs in to the ColdFusion site, we don't want them to have to log in again when visiting an ASP.NET page.
When someone logs in to the ColdFusion site, their username is stored in a cookie, along with a login token that can be looked up in our database. My .NET is a little rusty, so I'm having trouble visualizing how the ASP.NET code should use this data. I've already written a simple MembershipProvider that can be used to log in/out out the ASP.NET app using the data in our existing database tables, which are shared with the ColdFusion code.
What I'd like to know is - how can I make sure the ASP.NET app detects the cookies set by the ColdFusion app (I imagine they'd be sent to the ASP.NET pages, since everything is hosted on one domain), and automatically logs the user in using the MembershipProvider and Forms Authentication, using the credentials supplied in the cookie? I'm thinking that putting some kind of cookie check and log in function in the Global.asax file, set to run every page load for every page... but that seems kind of clunky. Also, do people still use the Global.asax file anyway? I had thought there was a more modern method.... Also, how can I manually log someone in using Forms Authentication and a custom membership provider? Currently my code allows the user to log in using the provided login control, but I'm not sure how to log the user in without them having to do anything.
Thanks in advance for any help. Looking over the MembershipProvider tutorials and the MSDN documentation it seems to me like the answer should be staring me in the face, but for some reason I just can't see it. Maybe not enough coffee....
Not sure if this is what you're looking for:
FormsAuthentication.SetAuthCookie("the username goes here",false);
Reference
I'm a CF developer ususally, but we had to do some integration with a .NET application recently and the way we approached it was to keep the CF and .NET sessions separate but ensure that login happened on both so when the user moved from one to the other they were still logged in.
So is there perhaps a way for you to hit your ASP.NET application with a request to login a user when you login using the CF application? Perhaps you could have an iframe on the page that you can load when the CF login is complete that holds a login service for the .NET app?
This way you would not need to worry about one app server reading the other app server's cookies, instead there would be two sets of cookies, one for ASP and one for CF.
Hope that helps!
The way I would approach it, is I would have a specific page that acts as a liaison between the CF and .NET layer. That page would implement your business layer and just check to see if the Cookie is there, if so read it in, do the lookup and login the user or whatever business logic that needs to be done. How would you accomplish the login/authentication, well that’s all based on your login/authentication code.
The only link I can offer is the basic of cookies in ASP.net
http://msdn.microsoft.com/en-us/library/aa289495(v=vs.71).aspx
Edit: found another link that might be helpful.
http://www.aspnettutorials.com/tutorials/network/cookies-csharp.aspx

Classic .ASP and .NET .aspx web pages in one ASP.NET Web app

We have an old web app written in classic ASP. We don't have the resources to rewrite the app.
I know that asp and aspx pages can coexist in the same ASP.NET web app, but it appears as those you cannot share Application and probably Session variables across these two groups of page extension types.
I was hoping to do new development in ASP.NET and to in theory, convert the Classic ASP pages over as we go.
Is there a way to share IIS variables across these two types of web pages (aside from passing information using the query string and forms fields)?
There is no straigthforwad solution for sharing session variables between classic ASP and ASP.NET. I would recommend you to persist sessions into a database, like it is described in this Microsoft Article. This way both ASP and ASP.NET can access session variables.
Not a direct way. You could consider using a shared database backend for your session state.
You could create a simple table in your DB to store the "session" info in. Both the classic asp and the .net pages could read and write there.
The only ways to pass this data would be GET/POST values, cookies, flat file, or storing the data to the database. There is nothing "Built In" to the .Net framework to do this.
I have seen another solution aside from using the database as shared session holder. I should say beforehand that using the database option is probably much better than this. But...
You can create an ASP page whose only function is to store into and retrieve from the ASP session state. From your ASPX page you can make a webrequest to your ASP page and return any session information in the header, querystring, or even do a scrape of the restulant load. Alternatively you can return an XML stream and make a poor man's web service.
I addition, you could get session state from ASP.NET by doing the opposite and making a .NET page that access session info and returns it.
It's not a good idea and fraught with security problems. I have seen it done is all I'm saying. It's really probably best to rely on the database and possibly pass session ID around.
Well I just have faced this problem, and want to tell you that just were able to solve it in one way. The solution was relatively easy and actually depends on your original development, in my case the system flow requires to log-in in a default.aspx page and after validating the user/password are correct the page Init.asp is executed and exactly there many session vars are created and loaded (actually are just the minimum needed) after that the last instruction redirects the user to mainmenu.aspx and form that page we call .aspx and .asp files.
This solution worked for me just because of the election the original developer made when designed this ASP 3.0 application and as you can imagine I can't retrieve those values in the asp.net pages.
I just went through this. My solution was to wrap it all in a nodejs app. I dole out JWT tokens from .NET web API that have all the users claims encoded in the payload. This token gets stored in a cookie on the client. The cookie will automatically get submitted on each request to your domain so all you need to do is read the cookie value from the header and decode the payload (in ASP.NET and Classic ASP independently). Once you read the contents, you can simply set the session variables to match those that were embedded in the JWT token.
I prefer this method because it has 0 database synchronization necessary and moves your application to OAuth2 openid and away from session.

Resources